@functionland/react-native-fula 1.9.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -205
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.idea/compiler.xml +1 -1
- package/android/.idea/gradle.xml +1 -0
- package/android/.idea/misc.xml +9 -9
- package/android/.idea/sonarlint/securityhotspotstore/index.pb +0 -0
- package/android/build.gradle +70 -69
- package/android/src/main/java/land/fx/fula/Cryptography.java +60 -60
- package/android/src/main/java/land/fx/fula/FulaModule.java +1477 -1384
- package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/protocols/fula.js +113 -98
- package/lib/commonjs/protocols/fula.js.map +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/protocols/fula.js +109 -96
- package/lib/module/protocols/fula.js.map +1 -1
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +2 -0
- package/lib/typescript/protocols/fula.d.ts +5 -0
- package/package.json +157 -157
- package/src/interfaces/fulaNativeModule.ts +122 -119
- package/src/protocols/fula.ts +301 -286
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
package land.fx.fula;
|
|
2
|
-
|
|
3
|
-
import android.util.Base64;
|
|
4
|
-
|
|
5
|
-
import java.io.UnsupportedEncodingException;
|
|
6
|
-
import java.nio.charset.StandardCharsets;
|
|
7
|
-
import java.security.InvalidAlgorithmParameterException;
|
|
8
|
-
import java.security.InvalidKeyException;
|
|
9
|
-
import java.security.NoSuchAlgorithmException;
|
|
10
|
-
import java.security.spec.InvalidKeySpecException;
|
|
11
|
-
import java.security.SecureRandom;
|
|
12
|
-
import java.nio.ByteBuffer;
|
|
13
|
-
import java.security.spec.InvalidParameterSpecException;
|
|
14
|
-
|
|
15
|
-
import javax.crypto.BadPaddingException;
|
|
16
|
-
import javax.crypto.Cipher;
|
|
17
|
-
import javax.crypto.IllegalBlockSizeException;
|
|
18
|
-
import javax.crypto.NoSuchPaddingException;
|
|
19
|
-
import javax.crypto.SecretKey;
|
|
20
|
-
import javax.crypto.SecretKeyFactory;
|
|
21
|
-
import javax.crypto.spec.PBEKeySpec;
|
|
22
|
-
import javax.crypto.spec.SecretKeySpec;
|
|
23
|
-
import javax.crypto.spec.GCMParameterSpec;
|
|
24
|
-
|
|
25
|
-
public class Cryptography {
|
|
26
|
-
public static String encryptMsg(String message, SecretKey secret)
|
|
27
|
-
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
|
|
28
|
-
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);
|
|
31
|
-
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
|
|
32
|
-
cipher.init(Cipher.ENCRYPT_MODE, secret, spec);
|
|
33
|
-
byte[] cipherText = cipher.doFinal(message.getBytes(StandardCharsets.UTF_8));
|
|
34
|
-
ByteBuffer byteBuffer = ByteBuffer.allocate(iv.length + cipherText.length);
|
|
35
|
-
byteBuffer.put(iv);
|
|
36
|
-
byteBuffer.put(cipherText);
|
|
37
|
-
return Base64.encodeToString(byteBuffer.array(), Base64.NO_WRAP);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public static String decryptMsg(String cipherText, SecretKey secret)
|
|
41
|
-
throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
|
|
42
|
-
ByteBuffer byteBuffer = ByteBuffer.wrap(Base64.decode(cipherText, Base64.NO_WRAP));
|
|
43
|
-
byte[] iv = new byte[12];
|
|
44
|
-
byteBuffer.get(iv);
|
|
45
|
-
byte[] cipherBytes = new byte[byteBuffer.remaining()];
|
|
46
|
-
byteBuffer.get(cipherBytes);
|
|
47
|
-
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
|
48
|
-
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
|
|
49
|
-
cipher.init(Cipher.DECRYPT_MODE, secret, spec);
|
|
50
|
-
String decryptString = new String(cipher.doFinal(cipherBytes), StandardCharsets.UTF_8);
|
|
51
|
-
return decryptString;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public static SecretKey generateKey(byte[] key)
|
|
55
|
-
throws NoSuchAlgorithmException, InvalidKeySpecException {
|
|
56
|
-
PBEKeySpec pbeKeySpec = new PBEKeySpec(StaticHelper.bytesToBase64(key).toCharArray(), key, 1000, 128);
|
|
57
|
-
SecretKey pbeKey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256").generateSecret(pbeKeySpec);
|
|
58
|
-
return new SecretKeySpec(pbeKey.getEncoded(), "AES");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
package land.fx.fula;
|
|
2
|
+
|
|
3
|
+
import android.util.Base64;
|
|
4
|
+
|
|
5
|
+
import java.io.UnsupportedEncodingException;
|
|
6
|
+
import java.nio.charset.StandardCharsets;
|
|
7
|
+
import java.security.InvalidAlgorithmParameterException;
|
|
8
|
+
import java.security.InvalidKeyException;
|
|
9
|
+
import java.security.NoSuchAlgorithmException;
|
|
10
|
+
import java.security.spec.InvalidKeySpecException;
|
|
11
|
+
import java.security.SecureRandom;
|
|
12
|
+
import java.nio.ByteBuffer;
|
|
13
|
+
import java.security.spec.InvalidParameterSpecException;
|
|
14
|
+
|
|
15
|
+
import javax.crypto.BadPaddingException;
|
|
16
|
+
import javax.crypto.Cipher;
|
|
17
|
+
import javax.crypto.IllegalBlockSizeException;
|
|
18
|
+
import javax.crypto.NoSuchPaddingException;
|
|
19
|
+
import javax.crypto.SecretKey;
|
|
20
|
+
import javax.crypto.SecretKeyFactory;
|
|
21
|
+
import javax.crypto.spec.PBEKeySpec;
|
|
22
|
+
import javax.crypto.spec.SecretKeySpec;
|
|
23
|
+
import javax.crypto.spec.GCMParameterSpec;
|
|
24
|
+
|
|
25
|
+
public class Cryptography {
|
|
26
|
+
public static String encryptMsg(String message, SecretKey secret)
|
|
27
|
+
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException {
|
|
28
|
+
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);
|
|
31
|
+
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
|
|
32
|
+
cipher.init(Cipher.ENCRYPT_MODE, secret, spec);
|
|
33
|
+
byte[] cipherText = cipher.doFinal(message.getBytes(StandardCharsets.UTF_8));
|
|
34
|
+
ByteBuffer byteBuffer = ByteBuffer.allocate(iv.length + cipherText.length);
|
|
35
|
+
byteBuffer.put(iv);
|
|
36
|
+
byteBuffer.put(cipherText);
|
|
37
|
+
return Base64.encodeToString(byteBuffer.array(), Base64.NO_WRAP);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public static String decryptMsg(String cipherText, SecretKey secret)
|
|
41
|
+
throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
|
|
42
|
+
ByteBuffer byteBuffer = ByteBuffer.wrap(Base64.decode(cipherText, Base64.NO_WRAP));
|
|
43
|
+
byte[] iv = new byte[12];
|
|
44
|
+
byteBuffer.get(iv);
|
|
45
|
+
byte[] cipherBytes = new byte[byteBuffer.remaining()];
|
|
46
|
+
byteBuffer.get(cipherBytes);
|
|
47
|
+
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
|
48
|
+
GCMParameterSpec spec = new GCMParameterSpec(128, iv);
|
|
49
|
+
cipher.init(Cipher.DECRYPT_MODE, secret, spec);
|
|
50
|
+
String decryptString = new String(cipher.doFinal(cipherBytes), StandardCharsets.UTF_8);
|
|
51
|
+
return decryptString;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public static SecretKey generateKey(byte[] key)
|
|
55
|
+
throws NoSuchAlgorithmException, InvalidKeySpecException {
|
|
56
|
+
PBEKeySpec pbeKeySpec = new PBEKeySpec(StaticHelper.bytesToBase64(key).toCharArray(), key, 1000, 128);
|
|
57
|
+
SecretKey pbeKey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256").generateSecret(pbeKeySpec);
|
|
58
|
+
return new SecretKeySpec(pbeKey.getEncoded(), "AES");
|
|
59
|
+
}
|
|
60
|
+
}
|