I would like to know if I could encrypt two or more strings in AES encryption.
Let’s say, I want to encrypt username, password and nonce_value. Can I use the following code?
try {
String codeWord = username, password, nonceInString;
String encryptedData = aseEncryptDecrypt.encrypt(codeWord);
String decryptedData = aseEncryptDecrypt.decrypt(encryptedData);
System.out.println("Encrypted : " + encryptedData);
System.out.println("Decrypted : " + decryptedData);
} catch (Throwable e) {
e.printStackTrace();
}
Well does that work? Why not try that code and see? In theory you certainly can put multiple pieces of data together into one string and encrypt that string, though you’d want a better way of putting the data together. Your current code, with commas between username, password, and nonceInString won’t compile, but if you can prevent, for instance, a colon existing in any of those strings, you could do something like:
And then when you decode simply split on the colon.