Reputation: 334
I'am trying to encrypt a String using AES-128 algorithm with given Key.
Implemented by Java, I used the solution here.
public static void main(String[] args) {
String key = "Bar12345Bar12345"; // 128 bit key
String initVector = "RandomInitVector"; // 16 bytes IV
System.out.println(encrypt(key, initVector, "System")));
}
Result:
encrypted string: iHvz04u8X7FPo7yagSLthA==
The above result is not what I want, I expect ZJfsFFLjl6YS0Xys5OUVIA==
to be the encrypted value of System
.
Like the flowing Test On : http://aesencryption.net/
Any propositions?
Upvotes: 0
Views: 493
Reputation: 73528
Your Java code is using an IV, while the web based encryption is not using one. For secure purposes, you should use a random IV so that encrypting the same data twice with the same key doesn't result in the same ciphertext. But if your requirement is to get the same result as from the web based one, leave out the initialization vector completely.
Upvotes: 1