diff --git a/android/src/main/java/com/tectiv3/aes/RCTAes.java b/android/src/main/java/com/tectiv3/aes/RCTAes.java index 2fe9b84..ec0d04b 100755 --- a/android/src/main/java/com/tectiv3/aes/RCTAes.java +++ b/android/src/main/java/com/tectiv3/aes/RCTAes.java @@ -215,7 +215,7 @@ private static String hmacX(String text, String key, String algorithm) final static IvParameterSpec emptyIvSpec = new IvParameterSpec(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); - private static String encrypt(String text, String hexKey, String hexIv) throws Exception { + private static String encrypt(String text, String hexKey, String hexIv, String algorithm) throws Exception { if (text == null || text.length() == 0) { return null; } @@ -223,13 +223,13 @@ private static String encrypt(String text, String hexKey, String hexIv) throws E byte[] key = Hex.decode(hexKey); SecretKey secretKey = new SecretKeySpec(key, KEY_ALGORITHM); - Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); + Cipher cipher = Cipher.getInstance(algorithm); cipher.init(Cipher.ENCRYPT_MODE, secretKey, hexIv == null ? emptyIvSpec : new IvParameterSpec(Hex.decode(hexIv))); byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8")); return Base64.encodeToString(encrypted, Base64.NO_WRAP); } - private static String decrypt(String ciphertext, String hexKey, String hexIv) throws Exception { + private static String decrypt(String ciphertext, String hexKey, String hexIv, String algorithm) throws Exception { if(ciphertext == null || ciphertext.length() == 0) { return null; } @@ -237,7 +237,7 @@ private static String decrypt(String ciphertext, String hexKey, String hexIv) th byte[] key = Hex.decode(hexKey); SecretKey secretKey = new SecretKeySpec(key, KEY_ALGORITHM); - Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); + Cipher cipher = Cipher.getInstance(algorithm); cipher.init(Cipher.DECRYPT_MODE, secretKey, hexIv == null ? emptyIvSpec : new IvParameterSpec(Hex.decode(hexIv))); byte[] decrypted = cipher.doFinal(Base64.decode(ciphertext, Base64.NO_WRAP)); return new String(decrypted, "UTF-8"); diff --git a/package.json b/package.json index ef6f514..2b43c38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-aes-crypto", - "version": "3.0.0", + "version": "3.0.1", "description": "AES crypto native module for react-native", "main": "index.js", "types": "index.d.ts",