I was wondering how can i limit my password to aplhanmeric based on the generated value of alphanumeric AES_ENCRYPT()
in mysql? I have a column password with a datatype of varbinary
Sample: select AES_ENCRYPT('enc开发者_如何学JAVAryption_code','password');
���"F]���\�L7z
I want to avoid the special characters.
This doesn't specifically answer the question on how to get just alphanumeric, but the 'special characters' look to be what MySQL does with utf8. You can see what they actually are in:
SELECT CONVERT(AES_ENCRYPT('encryption_code','password') USING latin1);
Now as to why you want just the alpha-numeric, may I ask why? Wouldn't that destroy the encryption when you go to AES_DECRYPT? With the above query, you can get the encryption_code back by doing:
SELECT AES_DECRYPT(CONVERT(AES_ENCRYPT('encryption_code','password') USING latin1), 'password');
精彩评论