Skip to content

Commit 3d27fb9

Browse files
Merged in bugfix/feature_delete_bug_fixes (pull request #212)
MRN-782,MRN-825,MRN-854,MRN-853,MRN-850,MRN-847,MRN-845,MRN-844,MRN-843,MRN-839,MRN-837,MRN-836,MRN-834,MRN-831,MRN-825,MRN-823,MRN-822,MRN-820,MRN-816,MRN-814, Approved-by: vanitha.g
2 parents c7c54cf + f331bfa commit 3d27fb9

File tree

83 files changed

+52897
-3050
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+52897
-3050
lines changed

android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ android {
8888
minSdkVersion rootProject.ext.minSdkVersion
8989
targetSdkVersion rootProject.ext.targetSdkVersion
9090
versionCode 1
91-
versionName "3.0.3"
91+
versionName "3.0.16"
9292
/** Add this for react-native-camera */
9393
missingDimensionStrategy 'react-native-camera', 'general'
9494
multiDexEnabled true

android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
3535
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE"/>
3636
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
37+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
3738

3839
<uses-feature
3940
android:name="android.hardware.camera"
@@ -112,7 +113,7 @@
112113
<service
113114
android:name="app.notifee.core.ForegroundService"
114115
android:exported="false"
115-
android:foregroundServiceType="mediaPlayback|camera|microphone|connectedDevice|shortService"
116+
android:foregroundServiceType="mediaPlayback|camera|microphone|connectedDevice|shortService|dataSync"
116117
tools:replace="android:foregroundServiceType"
117118
/>
118119
</application>

android/app/src/main/java/com/mirrorfly_rn/FileCryptLib.kt

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
package com.mirrorfly_rn
77

88

9+
import android.os.Build
10+
import android.util.Base64
911
import androidx.annotation.Keep
1012
import java.io.UnsupportedEncodingException
1113
import java.nio.charset.StandardCharsets
@@ -130,6 +132,91 @@ class FileCryptLib {
130132
return _cx // Return encrypted/decrypted cipher instance
131133
}
132134

135+
/**
136+
* @param inputByteArray Text to be encrypted or decrypted
137+
* @param encryptionKey Encryption key to used for encryption / decryption
138+
* @param mode specify the mode encryption / decryption
139+
* @param initVector Initialization vector
140+
* @return encrypted or decrypted string based on the mode
141+
* @throws UnsupportedEncodingException
142+
* @throws InvalidKeyException
143+
* @throws InvalidAlgorithmParameterException
144+
* @throws IllegalBlockSizeException
145+
* @throws BadPaddingException
146+
*/
147+
@Throws(
148+
UnsupportedEncodingException::class,
149+
InvalidKeyException::class,
150+
InvalidAlgorithmParameterException::class,
151+
IllegalBlockSizeException::class,
152+
BadPaddingException::class
153+
)
154+
private fun encryptDecryptFile(
155+
inputByteArray: ByteArray,
156+
encryptionKey: String,
157+
mode: EncryptMode,
158+
initVector: String
159+
): ByteArray {
160+
161+
var outPutByteArray = inputByteArray // Output byte array
162+
163+
/**
164+
* _encryptionKey = md5(_encryptionKey);
165+
* length of the key provided
166+
*/
167+
var len = encryptionKey.toByteArray(StandardCharsets.UTF_8).size
168+
if (encryptionKey.toByteArray(StandardCharsets.UTF_8).size > _key.size)
169+
len = _key.size
170+
171+
var ivlen = initVector.toByteArray(StandardCharsets.UTF_8).size
172+
if (initVector.toByteArray(StandardCharsets.UTF_8).size > _iv.size)
173+
ivlen = _iv.size
174+
175+
System.arraycopy(encryptionKey.toByteArray(StandardCharsets.UTF_8), 0, _key, 0, len)
176+
System.arraycopy(initVector.toByteArray(StandardCharsets.UTF_8), 0, _iv, 0, ivlen)
177+
178+
/**
179+
* Create a new SecretKeySpec
180+
*/
181+
val keySpec = SecretKeySpec(_key, "AES")
182+
183+
/**
184+
* Create a new IvParameterSpec instance with the bytes from the specified buffer iv
185+
* used as initialization vector.
186+
*/
187+
val ivSpec = IvParameterSpec(_iv)
188+
189+
if (mode == EncryptMode.ENCRYPT) { // Encryption
190+
/**
191+
* Read
192+
* https://android-developers.blogspot.com/2013/08/some-securerandom-thoughts.html
193+
* for more info.
194+
*/
195+
_cx.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec) // Initialize this cipher instance.
196+
val results = _cx.doFinal(inputByteArray)
197+
198+
val outputBytes = if (Build.VERSION.SDK_INT >= 26) {
199+
java.util.Base64.getEncoder().encode(results)
200+
} else Base64.encode(results, 0)
201+
202+
outPutByteArray = outputBytes // Multi-part, transformation and (encryption) Ciphertext
203+
}
204+
205+
if (mode == EncryptMode.DECRYPT) { // Decryption
206+
_cx.init(Cipher.DECRYPT_MODE, keySpec, ivSpec) // Initialize this cipher instance
207+
208+
val outputBytes = if (Build.VERSION.SDK_INT >= 26) {
209+
java.util.Base64.getDecoder().decode(inputByteArray)
210+
} else Base64.decode(inputByteArray, 0)
211+
212+
val decryptedVal = _cx.doFinal(outputBytes) // Finish
213+
214+
outPutByteArray = decryptedVal // Multi-part transformation(decryption)
215+
}
216+
217+
return outPutByteArray // Return encrypted/decrypted string
218+
}
219+
133220

134221
@SuppressWarnings("kotlin:S1133","kotlin:S107","kotlin:S1874")
135222
@Throws(
@@ -152,6 +239,10 @@ class FileCryptLib {
152239
return _cx // Return decrypted cipher instance
153240
}
154241

242+
fun decryptFile(_encryptedText: ByteArray, _key: String, _iv: String): ByteArray {
243+
return encryptDecryptFile(_encryptedText, _key, EncryptMode.DECRYPT, _iv)
244+
}
245+
155246
/***
156247
* This function computes the SHA256 hash of input string
157248
*

0 commit comments

Comments
 (0)