Able to encrypt the data but after decryption not able to convert to string. No errors received. Decryption is success only but couldn't get the correct string value getting some decrpyted value.Below is the code
if (MessageVal.contains("encrypt")) {
byte[] encrypted =result.getCryptoObject().getCipher().doFinal(message.getBytes());
String newmessage = Base64.encodeToString(encrypted, Base64.URL_SAFE);
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("messageValue", newmessage);
editor.apply();
Intent intent = new Intent(context, sampleAcitvity.class);
context.startActivity(intent);
} else if (MessageVal.contains("decrypt")) {
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(context);
String MessageFrm = sharedPreferences.getString("messageValue", null);
Toast.makeText(context, "b4value"+MessageFrm, Toast.LENGTH_LONG).show();
byte[] dataval= Base64.decode(MessageFrm, Base64.URL_SAFE);
byte[] data = result.getCryptoObject().getCipher().doFinal(dataval);
String stringDecryptyedval = new String(data, "UTF-8");
Toast.makeText(context, "sucessfully decrpted"+stringDecryptyedval, Toast.LENGTH_LONG).show();
Intent intent = new Intent(context, sampleAcitvity.class);
context.startActivity(intent);
}