Skip to content

Instantly share code, notes, and snippets.

@jetrubyshared
Created October 31, 2018 15:03
Show Gist options
  • Save jetrubyshared/fb8e9b0fdab1fce1336f448a36b9c938 to your computer and use it in GitHub Desktop.
Save jetrubyshared/fb8e9b0fdab1fce1336f448a36b9c938 to your computer and use it in GitHub Desktop.
private static String encryptString(String string) {
try {
if (initKeyStore() && initCipher() && initKey() && initCipherMode(Cipher.ENCRYPT_MODE)) {
byte[] bytes = sCipher.doFinal(string.getBytes());
return Base64.encodeToString(bytes, Base64.NO_WRAP);
}
} catch (IllegalBlockSizeException | BadPaddingException e) {
e.printStackTrace();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment