I am trying to encrypt a string
and using the Google's Tink
library.
When I call the method encrypt
and the encrypted string returns something like \<Ï~ß¾Ò0ÑP[oxRæ±E*;ÑRÂÉD«Øô§½:î
. I tried Base64.DEFAULT
, UTF-8
ISO-8859-1
, US-ASCI
and even StandarCharset.UTF_8
and similar charsets but nothing works. Please help, here is the snippet.
...
KeysetHandle keysetHandle = KeysetHandle.generateNew(AeadKeyTemplates.AES256_GCM);
Aead aead = AeadFactory.getPrimitive(keysetHandle);
byte [] str1 = str.getBytes("UTF-8");
...
byte [] output = aead.encrypt(str1, str2);
String outputStr = new String(output, "UTF-8");
...