I've run into a very strange circumstance and figured I would post here because I have no clue what's wrong. I have developed this android app that involves passwords and I have a user with a saved encrypted AES string saved to a file. When a user logs into the system again with their password I need to see whether it equals the encrypted on already in the file.
So I grabbed it and tried to compare the two strings using the .equals method like always and to my surprise it didn't work.
Here are the two strings: What am I missing? Any help would be greatly appreciated since I don't even have an first step on how to solve this. I also tried compareTo == 0 and it didn't work either.
Thank you very much!!!
The first string is from the file, the second is the encrypted version of the password the user just entered:
o0JkTVCBcbZnePszCKp64/cOJx/W/dud/xszfvNjwGk=
o0JkTVCBcbZnePszCKp64/cOJx/W/dud/xszfvNjwGk=
Base64 encoding is used to encode binary data into strings; the base64 string is not the data itself. To compare the data in the strings, first decode it to a byte array, then compare the byte arrays using the utility function in the Java Arrays
class. This should avoid issues with e.g. white space both in and around the encoding.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments