Skip to content

Commit 3cd98b3

Browse files
committed
obfuscating assets
1 parent f7a4490 commit 3cd98b3

5 files changed

Lines changed: 52 additions & 27 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ dependencies {
5555
})
5656
implementation 'com.android.support:appcompat-v7:28.0.0'
5757
testImplementation 'junit:junit:4.12'
58-
// implementation project(path: ':library')
58+
implementation project(path: ':library')
5959
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
60-
implementation "com.stringcare:library:$stringcare_version"
60+
// implementation "com.stringcare:library:$stringcare_version"
6161
}
6262

6363

app/src/main/assets/test.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"user": "user123",
3+
"message": "hello world"
4+
}

build.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ buildscript {
1616
}
1717

1818
dependencies {
19-
classpath "com.stringcare:plugin:$stringcare_version"
20-
// classpath files('../KotlinGradlePlugin/build/libs/plugin-3.1.jar')
21-
classpath 'com.android.tools.build:gradle:3.4.2'
19+
// classpath "com.stringcare:plugin:$stringcare_version"
20+
classpath files('../KotlinGradlePlugin/build/libs/plugin-3.3.jar')
21+
classpath 'com.android.tools.build:gradle:3.6.0-alpha06'
2222
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1"
2323
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
2424
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
@@ -44,7 +44,11 @@ apply plugin: StringCare
4444

4545
stringcare {
4646
debug true
47-
47+
modules {
48+
app {
49+
assetsFiles = ["*.json"]
50+
}
51+
}
4852
variants {
4953
prod {
5054
skip = true
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat May 25 04:13:40 CEST 2019
1+
#Fri Aug 16 21:23:15 CEST 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip

library/src/main/java/com/stringcare/library/CPlusLogic.kt

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ package com.stringcare.library
22

33
import android.content.Context
44
import android.content.res.Resources
5-
import android.os.Build
65
import android.support.annotation.StringRes
76
import java.nio.charset.Charset
8-
import java.util.*
7+
import kotlin.Exception
98

109
class CPlusLogic {
1110

@@ -75,8 +74,13 @@ class CPlusLogic {
7574
*/
7675
@JvmStatic
7776
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+
}
8084
}
8185

8286
/**
@@ -86,8 +90,12 @@ class CPlusLogic {
8690
*/
8791
@JvmStatic
8892
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+
}
9199
}
92100

93101
/**
@@ -125,11 +133,16 @@ class CPlusLogic {
125133
*/
126134
@JvmStatic
127135
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
133146
}
134147
}
135148

@@ -140,14 +153,18 @@ class CPlusLogic {
140153
*/
141154
@JvmStatic
142155
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
151168
}
152169
}
153170

0 commit comments

Comments
 (0)