Skip to content

Commit 7f57f04

Browse files
committed
Merge branch 'release/v3.0.1'
2 parents 9329512 + dbf70d1 commit 7f57f04

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

android/src/main/java/com/tectiv3/aes/RCTAes.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -215,29 +215,29 @@ private static String hmacX(String text, String key, String algorithm)
215215

216216
final static IvParameterSpec emptyIvSpec = new IvParameterSpec(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
217217

218-
private static String encrypt(String text, String hexKey, String hexIv) throws Exception {
218+
private static String encrypt(String text, String hexKey, String hexIv, String algorithm) throws Exception {
219219
if (text == null || text.length() == 0) {
220220
return null;
221221
}
222222

223223
byte[] key = Hex.decode(hexKey);
224224
SecretKey secretKey = new SecretKeySpec(key, KEY_ALGORITHM);
225225

226-
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
226+
Cipher cipher = Cipher.getInstance(algorithm);
227227
cipher.init(Cipher.ENCRYPT_MODE, secretKey, hexIv == null ? emptyIvSpec : new IvParameterSpec(Hex.decode(hexIv)));
228228
byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8"));
229229
return Base64.encodeToString(encrypted, Base64.NO_WRAP);
230230
}
231231

232-
private static String decrypt(String ciphertext, String hexKey, String hexIv) throws Exception {
232+
private static String decrypt(String ciphertext, String hexKey, String hexIv, String algorithm) throws Exception {
233233
if(ciphertext == null || ciphertext.length() == 0) {
234234
return null;
235235
}
236236

237237
byte[] key = Hex.decode(hexKey);
238238
SecretKey secretKey = new SecretKeySpec(key, KEY_ALGORITHM);
239239

240-
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
240+
Cipher cipher = Cipher.getInstance(algorithm);
241241
cipher.init(Cipher.DECRYPT_MODE, secretKey, hexIv == null ? emptyIvSpec : new IvParameterSpec(Hex.decode(hexIv)));
242242
byte[] decrypted = cipher.doFinal(Base64.decode(ciphertext, Base64.NO_WRAP));
243243
return new String(decrypted, "UTF-8");

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-aes-crypto",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "AES crypto native module for react-native",
55
"main": "index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)