开发者

Code igniter MySQL AES with active records?

How would i use code igniters active records to insert/update/select data from a database using mysql's built in aes encrypt/decrypt functions?

I know i could just use the normal sql query, but i'd like to use开发者_开发知识库 active records ideally.

Thanks


If you use the code provided previously:

$this->db->set('password',"AES_ENCRYPT('{$data['password']}','my_key')",FALSE);

you should still escape the password before passing it into db->set

use:

$pass = $this->db->escape($data['password']);

That way if the password contains special chars it won't kill the query


You can still use AES_Encrypt if you turn off escaping for that particular clause by passing FALSE as the last parameter:

$pass = $this->db->escape($data['password']);
$this->db->set('password', "AES_ENCRYPT('{$pass}','my_key')", FALSE);

Also point you to the CI built-in Encryption Class, and an article on considering 1-way encryption.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜