I have found the answer.
The reason is that we printed an array of bytes instead of a string.
The array will consist of a set of bytes so that we can see when we printed them in logcat.
To see the actual line, we just need to put the byte [] in a new line (byte []) - this is taken from the official facebook examples with my changes:
Crypto crypto = new Crypto(
new SharedPrefsBackedKeyChain(getActivity()),
new SystemNativeCryptoLibrary());
if (!crypto.isAvailable()) {
Log.e("Crypto","Crypto is missing");
}
String password = "Password";
Entity entity = new Entity("TEST");
byte[] encryptedPass = new byte[0];
byte[] b = password.getBytes(Charset.forName("UTF-8"));
try {
encryptedPass = crypto.encrypt(b, entity);
Log.e("Crypto Encrypted", new String(encryptedPass));
byte[] decryptedPass = crypto.decrypt(encryptedPass, entity);
Log.e("Crypto Decrypted ", new String(decryptedPass));
} catch (KeyChainException e) {
e.printStackTrace();
} catch (CryptoInitializationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Results:
08-02 19: 31:11.237 29364-29364/? E/Crypto Encrypted: 0 &? B 6 H ` " 1 xx 08-02 19: 31:11.237 29364-29364/? E/Crypto Decrypted: