I have this code to encrypt a string input. If i encrypt with same input on other devices os lower 8.1 then i get same value. However, when I try on the 8.1 devices, I get a completely different string. No exeption thrown. I found the Android 8.1 Cryptography updates with KeyGenerator:AES. How can i fix to generate a same value with other devices Os lower 8.1 ?
public static String cryptAESGungHo(String input)
{
byte[] gh_key = getKeyGungho("gh_key").getBytes();
byte[] gh_iv = getKeyGungho("gh_iv").getBytes();
IvParameterSpec ivSpecs = new IvParameterSpec(gh_iv);
byte[] crypted = null;
try{
SecretKeySpec skey = new SecretKeySpec(gh_key, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skey, ivSpecs);
try
{
crypted = cipher.doFinal(input.getBytes("UTF-16"));
}
catch(Exception e)
{}
}catch(Exception e){
}
String cr= new String(crypted);
return cr;
}