Skip to content

Commit a868d28

Browse files
authored
Merge pull request #62 from functionland/updated_wnfs_1.7.2
Updated wnfs 1.7.2
2 parents 8d85c2b + 2675a5f commit a868d28

File tree

7 files changed

+198
-256
lines changed

7 files changed

+198
-256
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dependencies {
6363
//noinspection GradleDynamicVersion
6464
implementation "com.facebook.react:react-native:+" // From node_modules
6565
implementation 'com.github.functionland:fula-build-aar:1.13.0' // From jitpack.io
66-
implementation 'com.github.functionland:wnfs-build-aar:v1.4.1' // From jitpack.io
66+
implementation 'com.github.functionland:wnfs-android:v1.7.3' // From jitpack.io
6767
implementation 'commons-io:commons-io:20030203.000550'
6868
implementation 'commons-codec:commons-codec:1.15'
6969
// implementation files('mobile.aar')

android/src/main/java/land/fx/fula/Cryptography.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
import javax.crypto.spec.GCMParameterSpec;
2424

2525
public class Cryptography {
26-
public static String encryptMsg(String message, SecretKey secret)
26+
public static String encryptMsg(String message, SecretKey secret, byte[] iv)
2727
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
2828
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
29-
byte[] iv = new byte[12]; // Ensure this is randomly generated for each encryption.
30-
new SecureRandom().nextBytes(iv);
29+
if (iv == null || iv.length == 0) {
30+
iv = new byte[12]; // Ensure this is randomly generated for each encryption.
31+
new SecureRandom().nextBytes(iv);
32+
}
3133
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
3234
cipher.init(Cipher.ENCRYPT_MODE, secret, spec);
3335
byte[] cipherText = cipher.doFinal(message.getBytes(StandardCharsets.UTF_8));

android/src/main/java/land/fx/fula/FulaModule.java

Lines changed: 46 additions & 85 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)