Possible Duplicate:
Javascript AES encryption
Is there a way to validate an AES encrypted string using javascript or jquery?
function ValidAES(str)
{
...
}
ValidAES("U2FsdGVkX1/pnQDBvA08BSX5Dx4X8KdIervCIte1JcU=");//true
ValidAES("@·$$%");//false
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your strings were simply AES encrypted, there would be no way to truly validate them — every string can be decrypted with AES. Most of the results are simply garbage.
In this case, it looks as though your strings are Base64 text. It’s not difficult to perform some simple checks to make sure there aren’t any invalid characters in there:
Note that this will still allow most random user input through, though. This is unavoidable, as some of this user input will be “valid” as far as Javascript can tell. If there is a particular length of AES string that you’re expecting, checking
string.lengthmight help.