3
I made my class in java for encryption using AES. However I went to test it on this site here: http://aesencryption.net/
Java class:
text: test
key: abcdefghijklmno1
outworking: 5brjBUDRtK7OzHLZf/Pv9a==
however the result of the site was different: 9rHpDdonevdWy+1PnTSweA==
public String encrypt(String Data, String pKey) throws Exception
{
Key key = generateKey(pKey);
Cipher c = Cipher.getInstance(ALGO);
c.init(Cipher.ENCRYPT_MODE, key);
byte[] encVal = c.doFinal(Data.getBytes("UTF-8"));
return new BASE64Encoder().encode(encVal);
}
The doubt is as follows which of the 2 encryptions is correct?
And look how cool, if I take the java class that they provide this is the result
tLVGNiaoZ1YQA68tNS8C4w==
. It’s all crazy, rsrs.– Gustavo Cinque
Can make your method available
generateKey()
? And also the StringALGO
.– Gustavo Cinque
private Key generateKey(String pKey) throws Exception
 {
 Key key = new SecretKeySpec(pKey.getBytes("UTF-8"), "AES");
 return key;
 }
– Rafael Pontin
private Static final String SOMETHING = "AES";
– Rafael Pontin
Thanks @Gustavocinque managed to solve XD.
– Rafael Pontin