MySQL有如下同名的加密函数
DECODE(crypt_str,pass_str) Decrypts the encrypted string crypt_str using pass_str as the password. crypt_str should be a string returned from ENCODE(). ENCODE(str,pass_str) Encrypt str using pass_str as the password. To decrypt the result, use DECODE(). The result is a binary string of the same length as str例子:
mysql> select encode('mysql','1234');
+------------------------+
| encode('mysql','1234') |
+------------------------+
| Oy蕣                  |
+------------------------+
1 row in set (0.22 sec)mysql> select decode(' Oy^D蕣','1234');
+-------------------------+
| decode(' Oy蕣','1234') |
+-------------------------+
| 褈醱                  |
+-------------------------+
1 row in set (0.02 sec)这里出错的原因可能是我复制字符串的时候有误!
因为下面这样做就没有错了mysql> select decode(encode('mysql','1234'),'1234');
+---------------------------------------+
| decode(encode('mysql','1234'),'1234') |
+---------------------------------------+
| mysql                                 |
+---------------------------------------+
1 row in set (0.03 sec)