Skip to content

Commit

Permalink
Merge pull request #62 from functionland/updated_wnfs_1.7.2
Browse files Browse the repository at this point in the history
Updated wnfs 1.7.2
  • Loading branch information
ehsan6sha authored Jul 16, 2023
2 parents 8d85c2b + 2675a5f commit a868d28
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 256 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.github.functionland:fula-build-aar:1.13.0' // From jitpack.io
implementation 'com.github.functionland:wnfs-build-aar:v1.4.1' // From jitpack.io
implementation 'com.github.functionland:wnfs-android:v1.7.3' // From jitpack.io
implementation 'commons-io:commons-io:20030203.000550'
implementation 'commons-codec:commons-codec:1.15'
// implementation files('mobile.aar')
Expand Down
8 changes: 5 additions & 3 deletions android/src/main/java/land/fx/fula/Cryptography.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
import javax.crypto.spec.GCMParameterSpec;

public class Cryptography {
public static String encryptMsg(String message, SecretKey secret)
public static String encryptMsg(String message, SecretKey secret, byte[] iv)
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
byte[] iv = new byte[12]; // Ensure this is randomly generated for each encryption.
new SecureRandom().nextBytes(iv);
if (iv == null || iv.length == 0) {
iv = new byte[12]; // Ensure this is randomly generated for each encryption.
new SecureRandom().nextBytes(iv);
}
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
cipher.init(Cipher.ENCRYPT_MODE, secret, spec);
byte[] cipherText = cipher.doFinal(message.getBytes(StandardCharsets.UTF_8));
Expand Down
131 changes: 46 additions & 85 deletions android/src/main/java/land/fx/fula/FulaModule.java

Large diffs are not rendered by default.

Loading

0 comments on commit a868d28

Please sign in to comment.