2011-11-24 04:38
浏览 84

PHP AES加密 - 无法解密存储在数据库中的某些值

I'm using to encrypt some values and store them in a MySQL database. The column type for the database is VARBINARY(512) which is the only one that seemed to work.

The values (plain text) are strings not longer than 128 chars but as this is my first take on something more serious than plain md5 or such I do think I'm doing something very bad here. First of all, the initialization vector is always the same, but this really isn't a concern for this project.

Problem is, when I decrypt the values, some values come out ok while other's not. Any idea what could the problem be here?

I'm using OFB cypher mode, 256 bit key and the values are email addresses and phone numbers.

Any help would be much appreciated.


图片转代码服务由CSDN问答提供 功能建议

我正在使用 加密某些值并将其存储在MySQL数据库中。 数据库的列类型是VARBINARY(512),它是唯一似乎工作的类型。

值(纯文本)是不超过128个字符的字符串,但这是我第一次接受比md5更严重的事情,或者我认为我做的事情非常糟糕 这里。 首先,初始化向量总是相同的,但这确实不是这个项目的关注点。

问题是,当我解密这些值时,某些值会正常,而其他值则没有。 知道这里有什么问题吗?

我正在使用OFB密码模式,256位密钥,值是电子邮件地址和电话号码。 < p>非常感谢任何帮助。


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dou4064 2011-11-24 05:04

    I had a similar problem. You have to change the column type to BLOB. If that doesn't work, try trimming your strings or data or whatever.

    Also, MySQL comes with AES functionality. Did you consider that?

    点赞 打赏 评论

相关推荐 更多相似问题