@@ -2,10 +2,9 @@ package com.stringcare.library
2
2
3
3
import android.content.Context
4
4
import android.content.res.Resources
5
- import android.os.Build
6
5
import android.support.annotation.StringRes
7
6
import java.nio.charset.Charset
8
- import java.util.*
7
+ import kotlin.Exception
9
8
10
9
class CPlusLogic {
11
10
@@ -75,8 +74,13 @@ class CPlusLogic {
75
74
*/
76
75
@JvmStatic
77
76
fun revealV2 (context : Context , @StringRes id : Int ): String {
78
- val arr: ByteArray = context.getString(id).split(" , " ).map { it.toInt().toByte() }.toByteArray()
79
- return String (SC ().jniRevealV2(context, getCertificateSHA1Fingerprint(context), arr))
77
+ val value = context.getString(id)
78
+ return try {
79
+ val arr: ByteArray = value.split(" , " ).map { it.toInt().toByte() }.toByteArray()
80
+ String (SC ().jniRevealV2(context, getCertificateSHA1Fingerprint(context), arr))
81
+ } catch (e: Exception ) {
82
+ value
83
+ }
80
84
}
81
85
82
86
/* *
@@ -86,8 +90,12 @@ class CPlusLogic {
86
90
*/
87
91
@JvmStatic
88
92
fun revealV2 (context : Context , value : String ): String {
89
- val arr: ByteArray = value.split(" , " ).map { it.toInt().toByte() }.toByteArray()
90
- return String (SC ().jniRevealV2(context, getCertificateSHA1Fingerprint(context), arr))
93
+ return try {
94
+ val arr: ByteArray = value.split(" , " ).map { it.toInt().toByte() }.toByteArray()
95
+ return String (SC ().jniRevealV2(context, getCertificateSHA1Fingerprint(context), arr))
96
+ } catch (e: Exception ) {
97
+ value
98
+ }
91
99
}
92
100
93
101
/* *
@@ -125,11 +133,16 @@ class CPlusLogic {
125
133
*/
126
134
@JvmStatic
127
135
fun revealV3 (context : Context , @StringRes id : Int , androidTreatment : Boolean ): String {
128
- val arr: ByteArray = context.getString(id).split(" , " ).map { it.toInt().toByte() }.toByteArray()
129
- val reveal = String (SC ().jniRevealV3(context, getCertificateSHA1Fingerprint(context), arr))
130
- return when (androidTreatment) {
131
- true -> reveal.unescape()
132
- false -> reveal
136
+ val value = context.getString(id)
137
+ return try {
138
+ val arr: ByteArray = value.split(" , " ).map { it.toInt().toByte() }.toByteArray()
139
+ val reveal = String (SC ().jniRevealV3(context, getCertificateSHA1Fingerprint(context), arr))
140
+ when (androidTreatment) {
141
+ true -> reveal.unescape()
142
+ false -> reveal
143
+ }
144
+ } catch (e: Exception ) {
145
+ value
133
146
}
134
147
}
135
148
@@ -140,14 +153,18 @@ class CPlusLogic {
140
153
*/
141
154
@JvmStatic
142
155
fun revealV3 (context : Context , value : String , androidTreatment : Boolean ): String {
143
- val arr: ByteArray = when (androidTreatment) {
144
- true -> value.unescape()
145
- false -> value
146
- }.split(" , " ).map { it.toInt().toByte() }.toByteArray()
147
- val reveal = String (SC ().jniRevealV3(context, getCertificateSHA1Fingerprint(context), arr))
148
- return when (androidTreatment) {
149
- true -> reveal.unescape()
150
- false -> reveal
156
+ return try {
157
+ val arr: ByteArray = when (androidTreatment) {
158
+ true -> value.unescape()
159
+ false -> value
160
+ }.split(" , " ).map { it.toInt().toByte() }.toByteArray()
161
+ val reveal = String (SC ().jniRevealV3(context, getCertificateSHA1Fingerprint(context), arr))
162
+ when (androidTreatment) {
163
+ true -> reveal.unescape()
164
+ false -> reveal
165
+ }
166
+ } catch (e: Exception ) {
167
+ value
151
168
}
152
169
}
153
170
@@ -162,6 +179,20 @@ class CPlusLogic {
162
179
return java.lang.String .format(Resources .getSystem().locale(), revealV3(context, id, androidTreatment), * formatArgs)
163
180
}
164
181
182
+ /* *
183
+ * Reveals the given ByteArray
184
+ * @param value
185
+ * @return String
186
+ */
187
+ @JvmStatic
188
+ fun revealByteArray (context : Context , value : ByteArray ): ByteArray {
189
+ return try {
190
+ SC ().jniRevealV3(context, getCertificateSHA1Fingerprint(context), value)
191
+ } catch (e: Exception ) {
192
+ value
193
+ }
194
+ }
195
+
165
196
}
166
197
167
198
}
0 commit comments