Skip to content

Commit e109e8a

Browse files
committed
Try to update decrypt method
1 parent ef8d8cb commit e109e8a

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

android/src/main/java/org/walletconnect/crypto/RCTAes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private static String decrypt(String ciphertext, String hexKey, String hexIv) th
142142
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
143143
cipher.init(Cipher.DECRYPT_MODE, secretKey, hexIv == null ? emptyIvSpec : new IvParameterSpec(Hex.decode(hexIv)));
144144
byte[] decrypted = cipher.doFinal(Base64.decode(ciphertext, Base64.NO_WRAP));
145-
return new String(decrypted, "UTF-8");
145+
return Base64.encodeToString(decrypted, Base64.NO_WRAP)
146146
}
147147

148148
}

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const AES = {
111111
return new Promise((resolve, reject) => {
112112
NativeModules.Aes.decrypt(cipherTextBase64, keyHex, ivHex)
113113
.then(textString => {
114-
const result = convertUtf8ToArrayBuffer(textString);
114+
const result = convertBase64ToArrayBuffer(textString);
115115
resolve(result);
116116
})
117117
.catch(error => reject(error));

ios/RCTCrypto/lib/Aes.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ + (NSString *) encrypt: (NSString *)clearText64 key: (NSString *)key iv: (NSStri
4242

4343
+ (NSString *) decrypt: (NSString *)cipherText key: (NSString *)key iv: (NSString *)iv {
4444
NSData *result = [self AES128CBC:@"decrypt" data:[[NSData alloc] initWithBase64EncodedString:cipherText options:0] key:key iv:iv];
45-
return [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding];
45+
return [result base64EncodedStringWithOptions:0];
4646
}
4747

4848
@end

0 commit comments

Comments
 (0)