Skip to content

Commit a47ef2a

Browse files
committed
AES: Fix Base64 decode call
1 parent 7b3c628 commit a47ef2a

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

android/src/main/java/com/pedrouid/crypto/RCTAes.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ private static String encrypt(String textBase64, String hexKey, String hexIv) th
115115

116116
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
117117
cipher.init(Cipher.ENCRYPT_MODE, secretKey, hexIv == null ? emptyIvSpec : new IvParameterSpec(Hex.decode(hexIv)));
118-
byte [] textBytes = java.util.Base64.getDecoder().decode(textBase64);
119-
byte[] encrypted = cipher.doFinal(textBytes);
118+
byte[] encrypted = cipher.doFinal(Base64.decode(textBase64, Base64.DEFAULT));
120119
return Base64.encodeToString(encrypted, Base64.NO_WRAP);
121120
}
122121

@@ -130,7 +129,7 @@ private static String decrypt(String ciphertext, String hexKey, String hexIv) th
130129

131130
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
132131
cipher.init(Cipher.DECRYPT_MODE, secretKey, hexIv == null ? emptyIvSpec : new IvParameterSpec(Hex.decode(hexIv)));
133-
byte[] decrypted = cipher.doFinal(Base64.decode(ciphertext, Base64.NO_WRAP));
132+
byte[] decrypted = cipher.doFinal(Base64.decode(ciphertext, Base64.DEFAULT));
134133
return Base64.encodeToString(decrypted, Base64.NO_WRAP);
135134
}
136135

0 commit comments

Comments
 (0)