├── .gitattributes
├── .github
└── FUNDING.yml
├── .gitignore
├── .project
├── LICENSE
├── README.md
├── StringCareSchema.png
├── _config.yml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── efraespada
│ │ └── stringobfuscator
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ ├── raw
│ │ │ └── test_array.json
│ │ └── test.json
│ ├── java
│ │ └── com
│ │ │ └── efraespada
│ │ │ └── stringobfuscator
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── efraespada
│ └── stringobfuscator
│ └── ExampleUnitTest.java
├── build.gradle
├── dynamic_feature_cell
├── .gitignore
├── build.gradle
└── src
│ └── main
│ └── AndroidManifest.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── index.md
├── library
├── .gitignore
├── CMakeLists.txt
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── efraespada
│ │ └── stringcarelibrary
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── stringcare
│ │ │ └── library
│ │ │ ├── AssetByteArrayListener.kt
│ │ │ ├── AssetListener.kt
│ │ │ ├── CPlusLogic.kt
│ │ │ ├── ContextListener.kt
│ │ │ ├── FingerPrint.kt
│ │ │ ├── HexUtils.kt
│ │ │ ├── JSONArrayListener.kt
│ │ │ ├── JSONObjectListener.kt
│ │ │ ├── JavaLogic.kt
│ │ │ ├── ResExt.kt
│ │ │ ├── SC.kt
│ │ │ ├── SCTextView.kt
│ │ │ ├── StringExt.kt
│ │ │ ├── StringcareException.kt
│ │ │ ├── Vars.kt
│ │ │ └── Version.kt
│ └── res
│ │ └── values
│ │ ├── attrs.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── efraespada
│ └── stringcarelibrary
│ └── ExampleUnitTest.java
├── sample.png
├── sample2.png
├── settings.gradle
└── white.png
/.gitattributes:
--------------------------------------------------------------------------------
1 | * linguist-language=Java
2 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | patreon: stringcare
2 | custom: ["https://www.paypal.me/efraespada"]
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | .idea/
3 | .gradle/
4 | build/
5 | local.properties
6 | library/.externalNativeBuild
7 | *.iml
8 | *.DS_Store
9 | .cxx/
10 | *.cpp
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | AndroidStringObfuscator
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright 2016 Efraín Espada
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://search.maven.org/search?q=g:%22io.github.stringcare%22%20AND%20a:%22library%22)
2 |
3 |
4 |
5 | StringCare Android Library
6 |
7 |
8 |
9 | #### [Flutter Support](https://github.com/StringCare/stringcare)
10 |
11 | #### [What Is StringCare](https://github.com/StringCare/AndroidLibrary/wiki/What-is-StringCare)
12 |
13 | #### [Implementation](https://github.com/StringCare/AndroidLibrary/wiki/Implementation)
14 |
15 | #### [Strings Usage](https://github.com/StringCare/AndroidLibrary/wiki/Strings-Usage)
16 |
17 | #### [Assets Usage](https://github.com/StringCare/AndroidLibrary/wiki/Assets-Usage)
18 |
19 | #### [Configuration](https://github.com/StringCare/AndroidLibrary/wiki/Configuration)
20 |
21 | #### [Publish APK](https://github.com/StringCare/AndroidLibrary/wiki/Publish-APK)
22 |
23 | #### [Limitations](https://github.com/StringCare/AndroidLibrary/wiki/Limitations)
24 |
25 | #### [Compatibility](https://github.com/StringCare/AndroidLibrary/wiki/Compatibility)
26 |
27 | #### [Tasks](https://github.com/StringCare/AndroidLibrary/wiki/Tasks)
28 |
29 | #### [Resource Tips](https://github.com/StringCare/AndroidLibrary/wiki/Resource-Tips)
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | License
39 | -------
40 |
41 | Licensed under the Apache License, Version 2.0 (the "License");
42 | you may not use this file except in compliance with the License.
43 | You may obtain a copy of the License at
44 |
45 | http://www.apache.org/licenses/LICENSE-2.0
46 |
47 | Unless required by applicable law or agreed to in writing, software
48 | distributed under the License is distributed on an "AS IS" BASIS,
49 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50 | See the License for the specific language governing permissions and
51 | limitations under the License.
52 |
53 |
--------------------------------------------------------------------------------
/StringCareSchema.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/StringCareSchema.png
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | title: Android String Obfuscator
2 | description: Android library to obfuscate Strings
3 | google_analytics:
4 | show_downloads: true
5 | theme: jekyll-theme-minimal
6 |
7 | gems:
8 | - jekyll-mentions
9 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | apply plugin: StringCare
5 |
6 | stringcare {
7 | debug true
8 | assetsFiles = ["*.json"]
9 | stringFiles = ['strings.xml']
10 | srcFolders = ['src/main']
11 | }
12 |
13 | android {
14 | compileSdkVersion 30
15 |
16 | defaultConfig {
17 | applicationId "com.efraespada.stringobfuscator"
18 | minSdkVersion 15
19 | targetSdkVersion 30
20 | versionCode 1
21 | versionName "1.0"
22 | }
23 |
24 | flavorDimensions "type"
25 |
26 | buildTypes {
27 | release {
28 | minifyEnabled false
29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
30 | }
31 | debug {
32 | minifyEnabled false
33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34 | }
35 | }
36 |
37 | productFlavors {
38 | prod {
39 | dimension "type"
40 | }
41 | dev {
42 | dimension "type"
43 | applicationId = "com.efraespada.otherobfuscator"
44 | }
45 | }
46 |
47 | compileOptions {
48 | sourceCompatibility 1.8
49 | targetCompatibility 1.8
50 | }
51 |
52 | aaptOptions {
53 | noCompress "json"
54 | }
55 | }
56 |
57 | dependencies {
58 | implementation fileTree(include: ['*.jar'], dir: 'libs')
59 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
60 | exclude group: 'com.android.support', module: 'support-annotations'
61 | })
62 | implementation 'androidx.appcompat:appcompat:1.3.0'
63 | testImplementation 'junit:junit:4.12'
64 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
65 | implementation 'commons-io:commons-io:2.5'
66 | implementation project(path: ':library')
67 | // implementation "com.stringcare:library:$stringcare_version"
68 | }
69 |
70 |
71 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/efrainespada/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/efraespada/stringobfuscator/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.efraespada.stringobfuscator;
2 |
3 | import android.content.Context;
4 | import androidx.test.platform.app.InstrumentationRegistry;
5 | import androidx.test.ext.junit.runners.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.efraespada.stringobfuscator", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/assets/raw/test_array.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "user": "user123",
4 | "message": "hello world"
5 | },
6 | {
7 | "user": "user456",
8 | "message": "hello there"
9 | }
10 | ]
--------------------------------------------------------------------------------
/app/src/main/assets/test.json:
--------------------------------------------------------------------------------
1 | {
2 | "user": "user123",
3 | "message": "hello world"
4 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/efraespada/stringobfuscator/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.efraespada.stringobfuscator
2 |
3 | import android.os.Bundle
4 | import android.view.View
5 | import android.widget.TextView
6 | import androidx.appcompat.app.AppCompatActivity
7 | import com.stringcare.library.*
8 | import com.stringcare.library.SC.Companion.init
9 | import com.stringcare.library.SC.Companion.reveal
10 |
11 | class MainActivity : AppCompatActivity() {
12 | override fun onCreate(savedInstanceState: Bundle?) {
13 | super.onCreate(savedInstanceState)
14 | setContentView(R.layout.activity_main)
15 | init(applicationContext)
16 | val password = getString(R.string.snake_msg_hidden)
17 | val original = reveal(password, Version.V3)
18 | val message = "Snake, the password is $password$original"
19 | (findViewById(R.id.programmatically_obfuscation) as TextView).text = message
20 | val numbers =
21 | getString(R.string.pattern, "hi", 3) + " is " + reveal(R.string.pattern, "hi", 3)
22 | (findViewById(R.id.pattern) as TextView).text = numbers
23 | val tvAuto = findViewById(R.id.auto_tv)
24 | findViewById(R.id.btn_change).setOnClickListener { v: View? ->
25 | if (tvAuto.isHtmlEnabled) {
26 | tvAuto.setHtmlSupport(!tvAuto.isHtmlEnabled)
27 | } else if (tvAuto.isRevealingValue) {
28 | tvAuto.setRevealed(!tvAuto.isRevealingValue)
29 | } else if (!tvAuto.isRevealingValue) {
30 | tvAuto.setRevealed(!tvAuto.isRevealingValue)
31 | tvAuto.setHtmlSupport(!tvAuto.isHtmlEnabled)
32 | }
33 | }
34 | val equals = reveal(R.string.hello_world_b) == getString(R.string.hello_world_a)
35 | val areEquals = "Same result: $equals"
36 | (findViewById(R.id.same_value) as TextView).text = areEquals
37 | val jsonObjectName = R.string.asset_json_file.reveal()
38 |
39 |
40 | findViewById(R.id.json_object).text = jsonObjectName.json().toString()
41 | findViewById(R.id.json_object_original).text =
42 | String(jsonObjectName.bytes { false })
43 |
44 |
45 | val jsonArrayName = R.string.asset_json_raw_file.reveal()
46 | findViewById(R.id.json_array).text = jsonArrayName.jsonArray().toString()
47 | findViewById(R.id.json_array_original).text =
48 | jsonArrayName.bytes { false }.toString()
49 |
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
19 |
20 |
31 |
32 |
43 |
44 |
54 |
55 |
64 |
65 |
73 |
74 |
83 |
84 |
92 |
93 |
102 |
103 |
112 |
113 |
125 |
126 |
136 |
137 |
146 |
147 |
160 |
161 |
170 |
171 |
181 |
182 |
191 |
192 |
201 |
202 |
213 |
214 |
224 |
225 |
226 |
227 |
228 |
229 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | String Obfuscator Sample
4 |
5 | Hello there
6 | General Kenobi .
7 |
8 | %1$s (%2$d)
9 | \n\nla-li-lu-le-lo\n\n🐍😄🍉 \n\n áéíóú ?
10 | Hello
11 | World
12 |
13 | Hello
14 | World
15 |
16 | Hello
17 | World
18 |
19 | test.json
20 | raw/test_array.json
21 | Long New Line Comparison
22 | HTML treatment
23 | Programmatically Obfuscation
24 | Patterns
25 | String resource disabling Android treatment:
26 | JSON Asset
27 | JSON Array Raw Asset
28 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/efraespada/stringobfuscator/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.efraespada.stringobfuscator;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 |
3 | ext {
4 | kotlin_version = '1.5.10'
5 | stringcare_version = '4.2.1'
6 | }
7 |
8 | repositories {
9 | google()
10 | maven {
11 | url "https://plugins.gradle.org/m2/"
12 | }
13 | }
14 |
15 | dependencies {
16 | classpath "io.github.stringcare:plugin:$stringcare_version"
17 | // classpath files('../KotlinGradlePlugin/build/libs/plugin-4.0.6.jar')
18 | classpath 'com.android.tools.build:gradle:4.2.1'
19 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
20 | }
21 |
22 | }
23 |
24 | allprojects {
25 | repositories {
26 | google()
27 | maven {
28 | url "https://plugins.gradle.org/m2/"
29 | }
30 | }
31 | }
32 |
33 | task clean(type: Delete) {
34 | delete rootProject.buildDir
35 | }
36 |
--------------------------------------------------------------------------------
/dynamic_feature_cell/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/dynamic_feature_cell/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.dynamic-feature'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 15
10 | targetSdkVersion 28
11 | versionCode 1
12 | versionName "1.0"
13 |
14 |
15 | }
16 |
17 |
18 | }
19 |
20 | dependencies {
21 | implementation fileTree(dir: 'libs', include: ['*.jar'])
22 | implementation project(':app')
23 | }
24 |
--------------------------------------------------------------------------------
/dynamic_feature_cell/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Aug 16 21:23:15 CEST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn ( ) {
37 | echo "$*"
38 | }
39 |
40 | die ( ) {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
165 | if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
166 | cd "$(dirname "$0")"
167 | fi
168 |
169 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
170 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/index.md:
--------------------------------------------------------------------------------
1 | ### Welcome to GitHub Pages.
2 | This automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here [using GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/), select a template crafted by a designer, and publish. After your page is generated, you can check out the new `gh-pages` branch locally. If you’re using GitHub Desktop, simply sync your repository and you’ll see the new branch.
3 |
4 | ### Designer Templates
5 | We’ve crafted some handsome templates for you to use. Go ahead and click 'Continue to layouts' to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved.
6 |
7 | ### Creating pages manually
8 | If you prefer to not use the automatic generator, push a branch named `gh-pages` to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.
9 |
10 | ### Authors and Contributors
11 | You can @mention a GitHub username to generate a link to their profile. The resulting `` element will link to the contributor’s GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.
12 |
13 | ### Support or Contact
14 | Having trouble with Pages? Check out our [documentation](https://help.github.com/pages) or [contact support](https://github.com/contact) and we’ll help you sort it out.
15 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.10.2)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | add_library( # Sets the name of the library.
14 | sc-native-lib
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).
20 | ../../stringcare-jni-android-library/lib/sc-native-lib.cpp)
21 |
22 | # Searches for a specified prebuilt library and stores the path as a
23 | # variable. Because CMake includes system libraries in the search path by
24 | # default, you only need to specify the name of the public NDK library
25 | # you want to add. CMake verifies that the library exists before
26 | # completing its build.
27 |
28 | find_library( # Sets the name of the path variable.
29 | log-lib
30 |
31 | # Specifies the name of the NDK library that
32 | # you want CMake to locate.
33 | log)
34 |
35 | # Specifies libraries CMake should link to your target library. You
36 | # can link multiple libraries, such as libraries you define in this
37 | # build script, prebuilt third-party libraries, or system libraries.
38 |
39 | target_link_libraries( # Specifies the target library.
40 | sc-native-lib
41 |
42 | # Links the target library to the log library
43 | # included in the NDK.
44 | ${log-lib})
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | id 'maven-publish'
5 | id 'signing'
6 | }
7 |
8 | android {
9 | compileSdkVersion 30
10 |
11 | defaultConfig {
12 | minSdkVersion 15
13 | targetSdkVersion 30
14 | versionCode 4
15 | versionName version
16 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
17 | externalNativeBuild {
18 | cmake {
19 | cppFlags "-fexceptions"
20 | }
21 | }
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | debug {
29 | minifyEnabled false
30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
31 | }
32 | }
33 | externalNativeBuild {
34 | cmake {
35 | version "3.10.2"
36 | path "CMakeLists.txt"
37 | }
38 | }
39 | ndkVersion '21.3.6528147'
40 | }
41 |
42 | dependencies {
43 | implementation fileTree(dir: 'libs', include: ['*.jar'])
44 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
45 | exclude group: 'com.android.support', module: 'support-annotations'
46 | })
47 | implementation 'androidx.appcompat:appcompat:1.3.0'
48 | implementation 'org.apache.commons:commons-lang3:3.9'
49 | testImplementation 'junit:junit:4.12'
50 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
51 | }
52 |
53 | def siteUrl = 'https://github.com/StringCare/AndroidLibrary'
54 | def gitUrl = 'https://github.com/StringCare/AndroidLibrary.git'
55 |
56 | group = "io.github.stringcare"
57 | version = "4.2.1"
58 |
59 | Properties properties = new Properties()
60 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
61 |
62 | task sourcesJar(type: Jar) {
63 | classifier = 'sources'
64 | from android.sourceSets.main.java.srcDirs
65 | }
66 |
67 | task javadoc(type: Javadoc) {
68 | exclude '**/**.java'
69 | exclude '**/**.kt'
70 | source = android.sourceSets.main.java.srcDirs
71 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
72 | }
73 |
74 | task javadocJar(type: Jar, dependsOn: javadoc) {
75 | classifier = 'javadoc'
76 | from javadoc.destinationDir
77 | }
78 |
79 | afterEvaluate {
80 | publishing {
81 | publications {
82 | library(MavenPublication) {
83 | artifacts = [javadocJar, sourcesJar]
84 | from components.release
85 | artifactId = "library"
86 | pom {
87 | packaging = 'aar'
88 | name = 'StringCareAndroidLibrary'
89 | description = "Stringcare Android library"
90 | url = siteUrl
91 | scm {
92 | connection = gitUrl
93 | developerConnection = gitUrl
94 | url = siteUrl
95 | }
96 | licenses {
97 | license {
98 | name = 'The Apache License, Version 2.0'
99 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
100 | }
101 | }
102 | developers {
103 | developer {
104 | id = 'efraespada'
105 | name = 'efraespada'
106 | email = 'efraespada@gmail.com'
107 | }
108 | }
109 | }
110 | }
111 | }
112 | repositories {
113 | maven {
114 | //def releaseRepo = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
115 | // def snapshotRepo = "https://oss.sonatype.org/content/repositories/snapshots/"
116 | url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
117 | credentials {
118 | username = properties["nexusUsername"]
119 | password = properties["nexusPassword"]
120 | }
121 | }
122 | }
123 | }
124 |
125 | signing {
126 | useGpgCmd()
127 | sign publishing.publications.library
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/efrainespada/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | -keepclasseswithmembernames class * {
20 | native ;
21 | }
22 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/efraespada/stringcarelibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.efraespada.stringcarelibrary;
2 |
3 | import android.content.Context;
4 | import androidx.test.platform.app.InstrumentationRegistry;
5 | import androidx.test.ext.junit.runners.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.efraespada.androidstringobfuscator.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/AssetByteArrayListener.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | interface AssetByteArrayListener : AssetListener {
4 | fun assetReady(byteArray: ByteArray)
5 | }
6 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/AssetListener.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | interface AssetListener
4 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/CPlusLogic.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import android.content.Context
4 | import android.content.res.Resources
5 | import androidx.annotation.StringRes
6 | import java.nio.charset.Charset
7 | import kotlin.Exception
8 |
9 | class CPlusLogic {
10 |
11 | companion object {
12 |
13 | /**
14 | * Obfuscates the given value
15 | * @param value
16 | * @return String
17 | */
18 | @JvmStatic
19 | fun obfuscateV1(context: Context, value: String): String {
20 | return SC().jniObfuscateV1(context, getCertificateSHA1Fingerprint(context), value)
21 | }
22 |
23 | /**
24 | * Reveals the given value
25 | * @param id
26 | * @return String
27 | */
28 | @JvmStatic
29 | fun revealV1(context: Context, @StringRes id: Int): String {
30 | return SC().jniRevealV1(context,
31 | getCertificateSHA1Fingerprint(context),
32 | context.getString(id))
33 | }
34 |
35 | /**
36 | * Reveals the given value
37 | * @param value
38 | * @return String
39 | */
40 | @JvmStatic
41 | fun revealV1(context: Context, value: String): String {
42 | return SC().jniRevealV1(context, getCertificateSHA1Fingerprint(context), value)
43 | }
44 |
45 | /**
46 | * Reveals the given value
47 | * @param id
48 | * @param formatArgs
49 | * @return
50 | */
51 | @JvmStatic
52 | fun revealV1(context: Context, @StringRes id: Int, formatArgs: Array): String {
53 | return java.lang.String.format(Resources.getSystem().locale(), revealV1(context, id), *formatArgs)
54 | }
55 |
56 | /**
57 | * Obfuscates the given value
58 | * @param value
59 | * @return String
60 | */
61 | @JvmStatic
62 | fun obfuscateV2(context: Context, value: String): String {
63 | val bytes = Charset.forName("UTF-8").encode(value)
64 | val arrO = ByteArray(bytes.remaining())
65 | bytes.get(arrO)
66 | val arr: ByteArray = SC().jniObfuscateV2(context, getCertificateSHA1Fingerprint(context), arrO)
67 | return arr.map { it.toInt() }.toString().replace("[", "").replace("]", "")
68 | }
69 |
70 | /**
71 | * Reveals the given value
72 | * @param id
73 | * @return String
74 | */
75 | @JvmStatic
76 | fun revealV2(context: Context, @StringRes id: Int): String {
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 | }
84 | }
85 |
86 | /**
87 | * Reveals the given value
88 | * @param value
89 | * @return String
90 | */
91 | @JvmStatic
92 | fun revealV2(context: Context, value: String): String {
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 | }
99 | }
100 |
101 | /**
102 | * Reveals the given value
103 | * @param id
104 | * @param formatArgs
105 | * @return
106 | */
107 | @JvmStatic
108 | fun revealV2(context: Context, @StringRes id: Int, formatArgs: Array): String {
109 | return java.lang.String.format(Resources.getSystem().locale(), revealV2(context, id), *formatArgs)
110 | }
111 |
112 | /**
113 | * Obfuscates the given value
114 | * @param value
115 | * @return String
116 | */
117 | @JvmStatic
118 | fun obfuscateV3(context: Context, value: String, androidTreatment: Boolean): String {
119 | val bytes = Charset.forName("UTF-8").encode(when (androidTreatment) {
120 | true -> value.androidTreatment()
121 | false -> value.unescape()
122 | })
123 | val arrO = ByteArray(bytes.remaining())
124 | bytes.get(arrO)
125 | val arr: ByteArray = SC().jniObfuscateV3(context, getCertificateSHA1Fingerprint(context), arrO)
126 | return arr.map { it.toInt() }.toString().replace("[", "").replace("]", "")
127 | }
128 |
129 | /**
130 | * Reveals the given value
131 | * @param id
132 | * @return String
133 | */
134 | @JvmStatic
135 | fun revealV3(context: Context, @StringRes id: Int, androidTreatment: Boolean): String {
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
146 | }
147 | }
148 |
149 | /**
150 | * Reveals the given value
151 | * @param value
152 | * @return String
153 | */
154 | @JvmStatic
155 | fun revealV3(context: Context, value: String, androidTreatment: Boolean): String {
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
168 | }
169 | }
170 |
171 | /**
172 | * Reveals the given value
173 | * @param id
174 | * @param formatArgs
175 | * @return
176 | */
177 | @JvmStatic
178 | fun revealV3(context: Context, @StringRes id: Int, androidTreatment: Boolean, formatArgs: Array): String {
179 | return java.lang.String.format(Resources.getSystem().locale(), revealV3(context, id, androidTreatment), *formatArgs)
180 | }
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 |
196 | }
197 |
198 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/ContextListener.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | interface ContextListener {
4 |
5 | fun contextReady()
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/FingerPrint.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import android.content.Context
4 | import android.content.pm.PackageManager
5 | import java.io.ByteArrayInputStream
6 | import java.io.UnsupportedEncodingException
7 | import java.security.MessageDigest
8 | import java.security.NoSuchAlgorithmException
9 | import java.security.cert.CertificateEncodingException
10 | import java.security.cert.CertificateFactory
11 | import java.security.cert.X509Certificate
12 | import javax.crypto.SecretKey
13 | import javax.crypto.spec.SecretKeySpec
14 |
15 | internal fun getCertificateSHA1Fingerprint(context: Context): String {
16 | return try {
17 | val packageInfo = context.packageManager.getPackageInfo(
18 | context.packageName,
19 | PackageManager.GET_SIGNATURES)
20 | val signatures = packageInfo!!.signatures
21 | val cert = signatures[0].toByteArray()
22 | val input = ByteArrayInputStream(cert)
23 |
24 | val cf = CertificateFactory.getInstance(certificate)
25 | val c = cf.generateCertificate(input) as X509Certificate
26 | val publicKey = MessageDigest.getInstance(sha1).digest(c.encoded)
27 | publicKey.asHexUpper
28 | } catch (e1: NoSuchAlgorithmException) {
29 | e1.printStackTrace()
30 | ""
31 | } catch (e1: CertificateEncodingException) {
32 | e1.printStackTrace()
33 | ""
34 | }
35 | }
36 |
37 | @Throws(NoSuchAlgorithmException::class)
38 | internal fun generateKey(key: String): SecretKey {
39 | return try {
40 | val digest = MessageDigest.getInstance(sha1)
41 | var passphrase = digest.digest(key.toByteArray(charset(codification)))
42 | passphrase = passphrase.copyOf(16)
43 | SecretKeySpec(passphrase, aes)
44 | } catch (e: UnsupportedEncodingException) {
45 | e.printStackTrace()
46 | SecretKeySpec(emptyArray().toByteArray(), aes)
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/HexUtils.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import org.apache.commons.lang3.StringEscapeUtils
4 | import java.util.*
5 |
6 | // https://gist.github.com/fabiomsr/845664a9c7e92bafb6fb0ca70d4e44fd
7 |
8 | val ByteArray.asHexLower inline get() = this.joinToString(separator = ":") { byte ->
9 | String.format("%02x", (byte.toInt() and 0xFF))
10 | }
11 |
12 | val ByteArray.asHexUpper inline get() = this.joinToString(separator = ":") { byte ->
13 | String.format("%02X", (byte.toInt() and 0xFF))
14 | }
15 |
16 | val String.hexAsByteArray inline get() = this.chunked(2).map { string ->
17 | string.toUpperCase(Locale.getDefault()).toInt(16).toByte()
18 | }.toByteArray()
19 |
20 | fun String.escape(): String = Regex.escape(this)
21 | fun String.unescape(): String = StringEscapeUtils.unescapeJava(this)
22 | fun String.removeNewLines(): String = this.replace("\n", "")
23 | fun String.androidTreatment(): String {
24 | val va = this.split(" ")
25 | val values = mutableListOf()
26 | va.forEach { value ->
27 | if (value.trim().isNotBlank()) {
28 | values.add(value.trim())
29 | }
30 | }
31 | return values.joinToString(separator = " ")
32 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/JSONArrayListener.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import org.json.JSONArray
4 |
5 | interface JSONArrayListener : AssetListener {
6 | fun assetReady(json: JSONArray)
7 | }
8 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/JSONObjectListener.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import org.json.JSONObject
4 |
5 | interface JSONObjectListener : AssetListener {
6 | fun assetReady(json: JSONObject)
7 | }
8 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/JavaLogic.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import android.content.Context
4 | import android.content.res.Resources
5 | import androidx.annotation.StringRes
6 | import java.nio.charset.Charset
7 | import javax.crypto.Cipher
8 | import javax.crypto.spec.SecretKeySpec
9 |
10 | class JavaLogic {
11 |
12 | companion object {
13 |
14 | @Throws(Exception::class)
15 | private fun encrypt(message: String, key: String): String {
16 | val data = message.toByteArray(charset(codification))
17 | val cipher = Cipher.getInstance(transformation)
18 | cipher.init(Cipher.ENCRYPT_MODE, generateKey(key))
19 | val encryptData = cipher.doFinal(data)
20 | return encryptData.asHexUpper
21 | }
22 |
23 | @Throws(Exception::class)
24 | private fun decrypt(message: String, key: String): String {
25 | val cipher = Cipher.getInstance(transformation)
26 | cipher.init(Cipher.DECRYPT_MODE, SecretKeySpec(generateKey(key).encoded, aes))
27 | return String(cipher.doFinal(message.hexAsByteArray), Charset.forName(codification))
28 | }
29 | /**
30 | * Encrypts the given value
31 | * @param value
32 | * @return String
33 | */
34 | internal fun encryptString(context: Context, value: String): String {
35 | return try {
36 | encrypt(value, getCertificateSHA1Fingerprint(context))
37 | } catch (e: Exception) {
38 | e.printStackTrace()
39 | value
40 | }
41 | }
42 |
43 | /**
44 | * Decrypts the given value
45 | * @param value
46 | * @return String
47 | */
48 | internal fun decryptString(context: Context, value: String): String {
49 | return try {
50 | decrypt(value, getCertificateSHA1Fingerprint(context))
51 | } catch (e: Exception) {
52 | e.printStackTrace()
53 | value
54 | }
55 | }
56 |
57 | /**
58 | * Decrypts the given ID
59 | * @param id
60 | * @return String
61 | */
62 | internal fun getString(context: Context, @StringRes id: Int): String {
63 | return try {
64 | decrypt(context.getString(id), getCertificateSHA1Fingerprint(context))
65 | } catch (e: Exception) {
66 | e.printStackTrace()
67 | context.getString(id) // returns original value, maybe not encrypted
68 | }
69 | }
70 |
71 | /**
72 | * Decrypts the given ID
73 | * @param id
74 | * @param formatArgs
75 | * @return String
76 | */
77 | internal fun getString(context: Context,
78 | @StringRes id: Int,
79 | formatArgs: Array): String {
80 | return java.lang.String.format(
81 | Resources.getSystem().locale(),
82 | getString(context, id),
83 | *formatArgs)
84 | }
85 |
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/ResExt.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import android.content.res.Resources
4 | import android.os.Build
5 | import java.util.*
6 |
7 | fun Resources.locale(): Locale {
8 | return when {
9 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> this.configuration.locales.get(0)
10 | else -> this.configuration.locale
11 | }
12 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/SC.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import android.content.Context
4 | import androidx.annotation.StringRes
5 | import android.util.Log
6 | import org.json.JSONArray
7 | import org.json.JSONObject
8 | import java.nio.charset.Charset
9 |
10 | /**
11 | * Created by efrainespada on 02/10/2016.
12 | */
13 |
14 | class SC {
15 |
16 | companion object {
17 |
18 | init {
19 | System.loadLibrary("sc-native-lib")
20 | }
21 |
22 | val context: Context
23 | get() = when (contextFun) {
24 | null -> throw StringcareException("Context not defined yet.")
25 | else -> contextFun!!()
26 | }
27 |
28 | private var contextFun: (() -> Context)? = null
29 |
30 | private val listeners = mutableListOf()
31 |
32 | /**
33 | * Context getter. Common implementation
34 | */
35 | @JvmStatic
36 | fun init(c: Context) {
37 | contextFun = { c }
38 | processPendingContextListener()
39 | }
40 |
41 | /**
42 | * Context getter. Lambda implementation
43 | */
44 | @JvmStatic
45 | fun init(context: () -> Context) {
46 | contextFun = context
47 | processPendingContextListener()
48 | }
49 |
50 | /**
51 | * Process pending context listeners
52 | */
53 | private fun processPendingContextListener() {
54 | if (listeners.isNotEmpty())
55 | listeners.forEach { it.contextReady() }
56 | }
57 |
58 | /**
59 | * Holds all context listeners.
60 | */
61 | @JvmStatic
62 | fun onContextReady(listener: ContextListener) {
63 | if (contextFun != null) {
64 | listener.contextReady()
65 | return
66 | }
67 | listeners.add(listener)
68 | }
69 |
70 | /**
71 | * Obfuscates the string value
72 | * @param value
73 | * @return String
74 | */
75 | @JvmStatic
76 | fun obfuscate(value: String): String {
77 | return obfuscate(value, defaultAndroidTreatment, defaultVersion)
78 | }
79 |
80 | /**
81 | * Obfuscates the given value
82 | * @param value
83 | * @param androidTreatment
84 | * @param version
85 | * @return String
86 | */
87 | @JvmStatic
88 | fun obfuscate(
89 | value: String,
90 | androidTreatment: Boolean = defaultAndroidTreatment,
91 | version: Version = defaultVersion
92 | ): String {
93 | return if (contextFun == null) {
94 | Log.e(tag, initializationNeeded)
95 | value
96 | } else when (version) {
97 | Version.V0 -> JavaLogic.encryptString(context, value)
98 | Version.V1 -> CPlusLogic.obfuscateV1(context, value)
99 | Version.V2 -> CPlusLogic.obfuscateV2(context, value)
100 | Version.V3 -> CPlusLogic.obfuscateV3(context, value, androidTreatment)
101 | }
102 | }
103 |
104 | /**
105 | * Reveals the Int (@StringRes) value
106 | * @param id
107 | * @return String
108 | */
109 | @JvmStatic
110 | fun reveal(@StringRes id: Int): String {
111 | return reveal(id, defaultVersion)
112 | }
113 |
114 | /**
115 | * Reveals the Int (@StringRes) value
116 | * @param id
117 | * @param androidTreatment
118 | * @return String
119 | */
120 | @JvmStatic
121 | fun reveal(
122 | @StringRes id: Int,
123 | androidTreatment: Boolean = defaultAndroidTreatment
124 | ): String {
125 | return reveal(id, androidTreatment, defaultVersion)
126 | }
127 |
128 | /**
129 | * Reveals the Int (@StringRes) value
130 | * @param id
131 | * @param version
132 | * @return String
133 | */
134 | @JvmStatic
135 | fun reveal(@StringRes id: Int, version: Version = defaultVersion): String {
136 | return reveal(id, defaultAndroidTreatment, version)
137 | }
138 |
139 | /**
140 | * Reveals the Int (@StringRes) value
141 | * @param id
142 | * @param androidTreatment
143 | * @param version
144 | * @return String
145 | */
146 | @JvmStatic
147 | fun reveal(
148 | @StringRes id: Int,
149 | androidTreatment: Boolean = defaultAndroidTreatment,
150 | version: Version = defaultVersion
151 | ): String {
152 | return if (contextFun == null) {
153 | Log.e(tag, initializationNeeded)
154 | ""
155 | } else when (version) {
156 | Version.V0 -> JavaLogic.getString(context, id)
157 | Version.V1 -> CPlusLogic.revealV1(context, id)
158 | Version.V2 -> CPlusLogic.revealV2(context, id)
159 | Version.V3 -> CPlusLogic.revealV3(context, id, androidTreatment)
160 | }
161 | }
162 |
163 | /**
164 | * Reveals the String value
165 | * @param value
166 | * @return String
167 | */
168 | @JvmStatic
169 | fun reveal(value: String): String {
170 | return reveal(value, defaultAndroidTreatment, defaultVersion)
171 | }
172 |
173 | /**
174 | * Reveals the String value
175 | * @param value
176 | * @param version
177 | * @return String
178 | */
179 | @JvmStatic
180 | fun reveal(value: String, version: Version = defaultVersion): String {
181 | return reveal(value, defaultAndroidTreatment, version)
182 | }
183 |
184 | /**
185 | * Reveals the String value
186 | * @param value
187 | * @param androidTreatment
188 | * @return String
189 | */
190 | @JvmStatic
191 | fun reveal(value: String, androidTreatment: Boolean): String {
192 | return reveal(value, androidTreatment, defaultVersion)
193 | }
194 |
195 | /**
196 | * Reveals the String value
197 | * @param value
198 | * @param androidTreatment
199 | * @param version
200 | * @return String
201 | */
202 | @JvmStatic
203 | fun reveal(
204 | value: String,
205 | androidTreatment: Boolean = defaultAndroidTreatment,
206 | version: Version = defaultVersion
207 | ): String {
208 | return if (contextFun == null) {
209 | Log.e(tag, initializationNeeded)
210 | value
211 | } else when (version) {
212 | Version.V0 -> JavaLogic.decryptString(context, value)
213 | Version.V1 -> CPlusLogic.revealV1(context, value)
214 | Version.V2 -> CPlusLogic.revealV2(context, value)
215 | Version.V3 -> CPlusLogic.revealV3(context, value, androidTreatment)
216 | }
217 | }
218 |
219 | /**
220 | * Reveals the Int (@StringRes) value with vararg
221 | * @param id
222 | * @param formatArgs
223 | * @return String
224 | */
225 | @JvmStatic
226 | fun reveal(@StringRes id: Int, vararg formatArgs: Any): String {
227 | return reveal(id, defaultAndroidTreatment, defaultVersion, formatArgs)
228 | }
229 |
230 | /**
231 | * Reveals the Int (@StringRes) value with vararg
232 | * @param id
233 | * @param version
234 | * @param formatArgs
235 | * @return String
236 | */
237 | @JvmStatic
238 | fun reveal(
239 | @StringRes id: Int,
240 | version: Version = defaultVersion,
241 | vararg formatArgs: Any
242 | ): String {
243 | return reveal(id, defaultAndroidTreatment, version, formatArgs)
244 | }
245 |
246 | /**
247 | * Reveals the Int (@StringRes) value with vararg
248 | * @param id
249 | * @param androidTreatment
250 | * @param formatArgs
251 | * @return String
252 | */
253 | @JvmStatic
254 | fun reveal(
255 | @StringRes id: Int,
256 | androidTreatment: Boolean = defaultAndroidTreatment,
257 | vararg formatArgs: Any
258 | ): String {
259 | return reveal(id, androidTreatment, defaultVersion, formatArgs)
260 | }
261 |
262 | /**
263 | * Reveals the Int (@StringRes) value with vararg
264 | * @param id
265 | * @param androidTreatment
266 | * @param version
267 | * @param formatArgs
268 | * @return String
269 | */
270 | @JvmStatic
271 | fun reveal(
272 | @StringRes id: Int,
273 | androidTreatment: Boolean = defaultAndroidTreatment,
274 | version: Version = defaultVersion,
275 | vararg formatArgs: Any
276 | ): String {
277 | return when (contextFun) {
278 | null -> {
279 | Log.e(tag, initializationNeeded)
280 | ""
281 | }
282 | else -> return when (version) {
283 | Version.V0 -> JavaLogic.getString(context, id, formatArgs[0] as Array)
284 | Version.V1 -> CPlusLogic.revealV1(context, id, formatArgs[0] as Array)
285 | Version.V2 -> CPlusLogic.revealV2(context, id, formatArgs[0] as Array)
286 | Version.V3 -> CPlusLogic.revealV3(
287 | context,
288 | id,
289 | androidTreatment,
290 | formatArgs[0] as Array
291 | )
292 | }
293 | }
294 | }
295 |
296 | private fun assetByteArray(path: String, predicate: () -> Boolean = { true }): ByteArray {
297 | val inputStream = context.assets.openFd(path)
298 | var bytes = inputStream.createInputStream().readBytes()
299 | if (predicate()) {
300 | bytes = CPlusLogic.revealByteArray(context, bytes)
301 | }
302 | return bytes
303 | }
304 |
305 | @JvmStatic
306 | fun asset(): Assets {
307 | return Assets()
308 | }
309 |
310 | }
311 |
312 | class Assets {
313 | fun json(path: String) = try {
314 | JSONObject(String(assetByteArray(path), Charset.forName("UTF-8")))
315 | } catch (e: Exception) {
316 | print(e)
317 | JSONObject()
318 | }
319 |
320 | fun jsonArray(path: String) = try {
321 | JSONArray(String(assetByteArray(path), Charset.forName("UTF-8")))
322 | } catch (e: Exception) {
323 | print(e)
324 | JSONArray()
325 | }
326 |
327 | fun bytes(path: String, predicate: () -> Boolean) = assetByteArray(path, predicate)
328 |
329 | fun bytes(path: String, predicate: Boolean) = bytes(path) { predicate }
330 |
331 | fun bytes(path: String) = bytes(path, true)
332 | }
333 |
334 | external fun jniObfuscateV1(context: Context, key: String, value: String): String
335 |
336 | external fun jniRevealV1(context: Context, key: String, value: String): String
337 |
338 | external fun jniObfuscateV2(context: Context, key: String, value: ByteArray): ByteArray
339 |
340 | external fun jniRevealV2(context: Context, key: String, value: ByteArray): ByteArray
341 |
342 | external fun jniObfuscateV3(context: Context, key: String, value: ByteArray): ByteArray
343 |
344 | external fun jniRevealV3(context: Context, key: String, value: ByteArray): ByteArray
345 |
346 | }
347 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/SCTextView.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import android.content.Context
4 | import android.text.Html
5 | import android.util.AttributeSet
6 | import androidx.appcompat.widget.AppCompatTextView
7 | import com.stringcare.library.SC.Companion.onContextReady
8 | import com.stringcare.library.SC.Companion.reveal
9 |
10 | /*
11 | * Credits to Narvelan:
12 | * https://github.com/StringCare/AndroidLibrary/issues/34
13 | */
14 | class SCTextView : AppCompatTextView {
15 | private var text: String? = null
16 | private var isHTML: Boolean?
17 | private var androidTreatment: Boolean?
18 | private var revealed: Boolean?
19 |
20 | constructor(context: Context?) : super(context!!) {
21 | isHTML = null
22 | revealed = null
23 | androidTreatment = null
24 | }
25 |
26 | constructor(context: Context?, attrs: AttributeSet) : super(
27 | context!!, attrs
28 | ) {
29 | isHTML = null
30 | revealed = null
31 | androidTreatment = null
32 | loadText(attrs)
33 | }
34 |
35 | constructor(context: Context?, attrs: AttributeSet, defStyleAttr: Int) : super(
36 | context!!, attrs, defStyleAttr
37 | ) {
38 | isHTML = null
39 | revealed = null
40 | androidTreatment = null
41 | loadText(attrs)
42 | }
43 |
44 | /**
45 | * Sets the initial parameters
46 | *
47 | * @param attrs {AttributeSet}
48 | */
49 | private fun loadText(attrs: AttributeSet) {
50 | val mFalse = "false"
51 | val mResourceAndroidSchema = "http://schemas.android.com/apk/res/android"
52 | val textName = "text"
53 | val mResourceSchema = "http://schemas.android.com/apk/res-auto"
54 | val htmlName = "htmlSupport"
55 | val revealValue = "reveal"
56 | val androidTreatmentName = "androidTreatment"
57 | text = attrs.getAttributeValue(mResourceAndroidSchema, textName)
58 | if (isHTML == null) {
59 | isHTML = !mFalse.equals(
60 | attrs.getAttributeValue(mResourceSchema, htmlName),
61 | ignoreCase = true
62 | )
63 | }
64 | if (revealed == null) {
65 | revealed = !mFalse.equals(
66 | attrs.getAttributeValue(mResourceSchema, revealValue),
67 | ignoreCase = true
68 | )
69 | }
70 | if (androidTreatment == null) {
71 | androidTreatment = !mFalse.equals(
72 | attrs.getAttributeValue(mResourceSchema, androidTreatmentName),
73 | ignoreCase = true
74 | )
75 | }
76 | reloadText()
77 | }
78 |
79 | /**
80 | * Prints text with the given conditions
81 | */
82 | private fun reloadText() {
83 | if (text != null) {
84 | try {
85 | val rawValue = text!!.substring(1).toInt()
86 | if (!isRevealingValue) {
87 | setText(context.getString(rawValue))
88 | return
89 | }
90 | onContextReady(object : ContextListener {
91 | override fun contextReady() {
92 | val value = reveal(rawValue, usesAndroidTreatment())
93 | if (isHtmlEnabled) {
94 | setText(Html.fromHtml(value))
95 | } else {
96 | setText(value)
97 | }
98 | }
99 | })
100 | } catch (e: NumberFormatException) {
101 | setText(text)
102 | }
103 | }
104 | }
105 |
106 | /**
107 | * Reveals the value before print it
108 | *
109 | * @param revealed {true|false}
110 | */
111 | fun setRevealed(revealed: Boolean) {
112 | this.revealed = revealed
113 | reloadText()
114 | }
115 |
116 | /**
117 | * Enables HTML printing
118 | *
119 | * @param enabled {true|false}
120 | */
121 | fun setHtmlSupport(enabled: Boolean) {
122 | isHTML = enabled
123 | reloadText()
124 | }
125 |
126 | /**
127 | * Enables the Android treatment
128 | *
129 | * @param enabled {true|false}
130 | */
131 | fun setAndroidTreatment(enabled: Boolean) {
132 | androidTreatment = enabled
133 | reloadText()
134 | }
135 |
136 | /**
137 | * Returns true if is the value must be print as HTML
138 | *
139 | * @return Boolean
140 | */
141 | val isHtmlEnabled: Boolean
142 | get() = java.lang.Boolean.TRUE == isHTML
143 |
144 | /**
145 | * Returns true if the value must be treated as the Android system does
146 | *
147 | * @return Boolean
148 | */
149 | fun usesAndroidTreatment(): Boolean {
150 | return java.lang.Boolean.TRUE == androidTreatment
151 | }
152 |
153 | /**
154 | * Returns true if the value should be setRevealed before print it
155 | *
156 | * @return Boolean
157 | */
158 | val isRevealingValue: Boolean
159 | get() = java.lang.Boolean.TRUE == revealed
160 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/StringExt.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | import org.json.JSONArray
4 | import org.json.JSONObject
5 |
6 | fun Int.string(): String = SC.context.getString(this)
7 |
8 | fun Int.reveal(
9 | androidTreatment: Boolean = defaultAndroidTreatment,
10 | version: Version = defaultVersion
11 | ): String = SC.reveal(this, androidTreatment, version)
12 |
13 | fun Int.reveal(
14 | vararg formatArgs: Any,
15 | androidTreatment: Boolean = defaultAndroidTreatment,
16 | version: Version = defaultVersion
17 | ): String = SC.reveal(this, androidTreatment, version, formatArgs)
18 |
19 | fun String.obfuscate(
20 | androidTreatment: Boolean = defaultAndroidTreatment,
21 | version: Version = defaultVersion
22 | ): String = SC.obfuscate(this, androidTreatment, version)
23 |
24 | fun String.reveal(
25 | androidTreatment: Boolean = defaultAndroidTreatment,
26 | version: Version = defaultVersion
27 | ): String = SC.reveal(this, androidTreatment, version)
28 |
29 | fun String.json(): JSONObject = SC.asset().json(this)
30 |
31 | fun String.jsonArray(): JSONArray = SC.asset().jsonArray(this)
32 |
33 | fun String.bytes(
34 | predicate: () -> Boolean = { true }
35 | ): ByteArray = SC.asset().bytes(this, predicate)
36 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/StringcareException.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | open class StringcareException(message: String): Exception(message)
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/Vars.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | internal val defaultVersion = Version.V3
4 | internal const val defaultAndroidTreatment = true
5 | internal val tag = SC::class.java.simpleName
6 | internal const val codification = "UTF-8"
7 | internal const val sha1 = "SHA-1"
8 | internal const val aes = "AES"
9 | internal const val certificate = "X509"
10 | internal const val transformation = "AES/ECB/PKCS5Padding"
11 | internal const val initializationNeeded = "Library not initialized: SC.init(Context)"
12 |
--------------------------------------------------------------------------------
/library/src/main/java/com/stringcare/library/Version.kt:
--------------------------------------------------------------------------------
1 | package com.stringcare.library
2 |
3 | enum class Version {
4 | V0,
5 | V1,
6 | V2,
7 | V3
8 | }
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | StringCareLibrary
3 |
4 |
--------------------------------------------------------------------------------
/library/src/test/java/com/efraespada/stringcarelibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.efraespada.stringcarelibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/sample.png
--------------------------------------------------------------------------------
/sample2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/sample2.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------
/white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StringCare/AndroidLibrary/938672ec09e5b5f86c9bca4738aa3e505a6f5a35/white.png
--------------------------------------------------------------------------------