|
1 | | -<p align="center"><img width="10%" vspace="20" src="https://raw.githubusercontent.com/StringCare/AndroidLibrary/develop/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png"></p> |
| 1 | +<p align="center"><img width="10%" vspace="10" src="https://github.com/StringCare/AndroidLibrary/raw/develop/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png"></p> |
2 | 2 |
|
| 3 | +<h3 align="center" style="margin-bottom:30px" vspace="20">StringCare Android Library</h3> |
3 | 4 |
|
| 5 | +<p align="center"><img width="10%" vspace="20" src="https://github.com/StringCare/AndroidLibrary/raw/develop/white.png"></p> |
4 | 6 |
|
5 | | -String Care Android Library |
6 | | -========================= |
| 7 | +#### [Wiki Library](https://github.com/StringCare/AndroidLibrary/wiki) |
7 | 8 |
|
8 | | -Hide strings easily with that lib and plugin! It uses AES/ECB/PKCS5Padding transformation to convert strings with your app's SHA1 fingerprint. |
| 9 | +#### [What is StringCare](https://github.com/StringCare/AndroidLibrary/wiki/What-is-StringCare) |
9 | 10 |
|
10 | | -Gradle implementation |
11 | | ------------- |
| 11 | +#### [Library Implementation](https://github.com/StringCare/AndroidLibrary/wiki/Library-Implementation) |
12 | 12 |
|
13 | | -```groovy |
14 | | -// root_project/build.gradle |
15 | | - |
16 | | -buildscript { |
17 | | - |
18 | | - ext { |
19 | | - stringcare_version = '0.8' |
20 | | - } |
21 | | - |
22 | | - repositories { |
23 | | - jcenter() |
24 | | - } |
25 | | - |
26 | | - dependencies { |
27 | | - classpath "com.stringcare:plugin:$stringcare_version" |
28 | | - } |
29 | | - |
30 | | -} |
31 | | - |
32 | | -apply plugin: StringCare |
33 | | -``` |
| 13 | +#### [Library Usage](https://github.com/StringCare/AndroidLibrary/wiki/Library-Usage) |
34 | 14 |
|
35 | | -```groovy |
36 | | -// root_project/your_module/build.gradle |
| 15 | +#### [Publish APK](https://github.com/StringCare/AndroidLibrary/wiki/Publish-APK) |
37 | 16 |
|
38 | | -repositories { |
39 | | - jcenter() |
40 | | -} |
41 | | - |
42 | | -dependencies { |
43 | | - implementation "com.stringcare:library:$stringcare_version" |
44 | | -} |
45 | | -``` |
| 17 | +#### [Limitations](https://github.com/StringCare/AndroidLibrary/wiki/Limitations) |
46 | 18 |
|
47 | | -Setup |
48 | | ------ |
49 | | -StringCare library needs the global application's `Context` for access to `PackageManager` and get signatures. |
50 | | -In your `app` (or main) module the package name is obtained from `Context`: |
51 | | -```java |
52 | | -SC.init(getApplicationContext()); |
53 | | -``` |
54 | | - |
55 | | -In the rest of modules (or libraries) you must pass an `Object` in order to obtain its package name: |
56 | | -```java |
57 | | -SC.initForLib(getApplicationContext(), this); |
58 | | -``` |
59 | | - |
60 | | - |
61 | | -#### Encrypt |
62 | | -The plugin will encrypt all string tags with `hidden="true"` as attribute. |
63 | | - |
64 | | -```xml |
65 | | -<resources> |
66 | | - <string name="app_name">StringObfuscator</string> |
67 | | - <string name="hello" hidden="true">hello world!</string> |
68 | | - <string name="test_a" hidden="true">%1$s (%2$d)</string> |
69 | | -</resources> |
70 | | -``` |
71 | | - |
72 | | -Or encrypt strings programmatically by doing: |
73 | | - |
74 | | -```java |
75 | | -String encrypted = SC.encryptString(string_var); |
76 | | -``` |
77 | | - |
78 | | -#### Decrypt |
79 | | -From resources: |
80 | | -```java |
81 | | -String decrypted = SC.getString(R.string.hello); |
82 | | -String decrypted = SC.getString(R.string.test_a, "hi", 3); // hi (3) |
83 | | -``` |
84 | | -Or from encrypted variables: |
85 | | -```java |
86 | | -String decrypted = SC.decryptString(encrypted_var); |
87 | | -``` |
88 | | -Sample |
89 | | ------- |
90 | | - |
91 | | -```java |
92 | | -SC.init(getApplicationContext()); |
93 | | - |
94 | | -// getting encrypted string resources |
95 | | -int stringId = R.string.hello; |
96 | | - |
97 | | -String message = getString(stringId); |
98 | | -message += " is "; |
99 | | -message += SC.getString(stringId); |
100 | | - |
101 | | -// and secret |
102 | | -String mySecret = "lalilulelo"; |
103 | | - |
104 | | -message += "\n\nFor Metal Gear lovers:\n\n\"Snake, the password is " + |
105 | | - SC.encryptString(mySecret) + |
106 | | - "\n\n.. or " + |
107 | | - SC.decryptString(SC.encryptString(mySecret)) + |
108 | | - "\""; |
109 | | - |
110 | | -((TextView) findViewById(R.id.example)).setText(message); |
111 | | -``` |
112 | | - |
113 | | -<p align="center"><img width="40%" vspace="20" src="https://raw.githubusercontent.com/efraespada/AndroidStringObfuscator/master/sample.png"></p> |
114 | | - |
115 | | -Library Sample |
116 | | --------------- |
117 | | -```java |
118 | | -public class YourApplication extends Application { |
119 | | - |
120 | | - @Override |
121 | | - public void onCreate() { |
122 | | - super.onCreate(); |
123 | | - Library.init(this); |
124 | | - String secretPass = Library.getPassword(); // should return -> =^UCrE4zR#}kpCu~ |
125 | | - } |
126 | | - |
127 | | -} |
128 | | -``` |
129 | | -In library package: |
130 | | -```java |
131 | | -public class Library { |
132 | | - |
133 | | - private Library() { |
134 | | - // .. |
135 | | - } |
136 | | - |
137 | | - public static void init(Context context) { |
138 | | - SC.initForLib(context, new Library()); |
139 | | - } |
140 | | - |
141 | | - public static String getPassword() { |
142 | | - return SC.getString(your.lib.module.R.string.pass); |
143 | | - } |
144 | | - |
145 | | -} |
146 | | -``` |
147 | | -```xml |
148 | | -<resources> |
149 | | - <string name="pass" hidden="true">=^UCrE4zR#}kpCu~</string> |
150 | | -</resources> |
151 | | -``` |
152 | | - |
153 | | -Configuration |
154 | | ------------------------------ |
155 | | -By default the plugin will encrypt every `strings.xml` file inside `src/main`folder but you can choose a different configuration. |
156 | | -```groovy |
157 | | -// root_folder/build.gradle |
158 | | - |
159 | | -apply plugin: StringCare |
160 | | - |
161 | | -stringcare { |
162 | | - |
163 | | - debug true // prints details |
164 | | - |
165 | | - modules { |
166 | | - |
167 | | - sample { |
168 | | - stringFiles = ['strings.xml',"other_file.xml"] |
169 | | - srcFolders = ['src/main', "other_folder"] |
170 | | - } |
171 | | - |
172 | | - // root_folder/sample/src/main/res/.../strings.xml |
173 | | - // root_folder/sample/src/main/res/.../other_file.xml |
174 | | - // root_folder/sample/other_folder/res/.../strings.xml |
175 | | - // root_folder/sample/other_folder/res/.../other_file.xml |
176 | | - |
177 | | - other_module { |
178 | | - srcFolders = ['src/moduleB'] |
179 | | - } |
180 | | - |
181 | | - // root_folder/other_module/src/moduleB/res/.../strings.xml |
182 | | - |
183 | | - other_module_ {} // |
184 | | - |
185 | | - // root_folder/other_module_/src/main/res/.../strings.xml |
186 | | - |
187 | | - } |
188 | | - |
189 | | -} |
190 | | -``` |
191 | | - |
192 | | -Gradle Console Output Example |
193 | | ------------------------------ |
194 | | -``` |
195 | | -... |
196 | | -:sample:generateDebugResValues UP-TO-DATE |
197 | | -:sample:generateDebugResources UP-TO-DATE |
198 | | -:sample:mergeDebugResources |
199 | | -:sample:debug:B8:DC:47:58:9B:5F:2C:21:45:C4:04:37:0E:56:53:DC:24:6B:2C:66 |
200 | | -:sample:backupStringResources |
201 | | - - values/strings.xml |
202 | | -:sample:encryptStringResources |
203 | | - - values/strings.xml |
204 | | - [hello world!] - [A8590C43DA85D67..] |
205 | | -:sample:mergeDebugResources UP-TO-DATE |
206 | | -:sample:restoreStringResources |
207 | | - - values/strings.xml |
208 | | -:sample:createDebugCompatibleScreenManifests UP-TO-DATE |
209 | | -... |
210 | | -``` |
211 | | - |
212 | | -Plugin won't work if there is no config defined for the selected variant: |
213 | | -```bash |
214 | | -... |
215 | | -:sample:mergeReleaseResources |
216 | | - 🤯 no config defined for variant release |
217 | | -:sample:createReleaseCompatibleScreenManifests |
218 | | -... |
219 | | -``` |
| 19 | +#### [Wiki Plugin](https://github.com/StringCare/GradlePlugin/wiki) |
220 | 20 |
|
221 | 21 | License |
222 | 22 | ------- |
|
0 commit comments