Skip to content

Commit b0e0de4

Browse files
authored
Merge pull request #4 from efraespada/develop
Develop
2 parents 540e179 + a0e5a79 commit b0e0de4

File tree

11 files changed

+198
-135
lines changed

11 files changed

+198
-135
lines changed

README.md

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,78 @@ repositories {
1616
}
1717
1818
dependencies {
19-
compile 'efraespada:androidstringobfuscator:0.2'
19+
compile 'efraespada:androidstringobfuscator:0.4'
2020
}
2121
2222
android.applicationVariants.all{ variant ->
23-
24-
variant.mergeResources.doLast{
25-
println ":" + project.name + ":initStringObfuscator"
26-
javaexec {
27-
main = "-jar";
28-
args = [
29-
"../AndroidStringObfuscator.jar",
30-
project.name,
31-
variant.dirName
32-
]
33-
}
34-
}
23+
variant.mergeResources.doLast{
24+
println ":" + project.name + ":initStringObfuscator"
25+
javaexec {
26+
main = "-jar";
27+
args = [
28+
"../AndroidStringObfuscator.jar",
29+
project.name,
30+
variant.dirName
31+
]
32+
}
33+
}
3534
}
3635
```
3736

37+
Setup
38+
-----
39+
Init the library:
40+
```java
41+
AndroidStringObfuscator.init(this);
42+
```
43+
3844

39-
Encrypt Strings
40-
---------------
45+
#### Encrypt
4146
The script will encrypt all string tags with `hidden="true"` as attribute.
4247

4348
```xml
4449
<resources>
45-
<string name="hello">hello world!</string>
46-
<string name="app_name" hidden="true">StringObfuscator</string>
50+
<string name="hello" hidden="true">hello world!</string>
51+
<string name="app_name">StringObfuscator</string>
4752
</resources>
4853
```
4954

5055
Or encrypt strings programmatically by doing:
5156

5257
```java
53-
String encrypted = AndroidStringObfuscator.simulateString(context, some_string_var);
58+
String encrypted = AndroidStringObfuscator.encryptString(some_string_var);
5459
```
5560

56-
Decrypt Strings
57-
---------------
61+
#### Decrypt
62+
From resources:
5863
```java
59-
String decrypted = AndroidStringObfuscator.getString(context, R.string.app_name);
64+
String decrypted = AndroidStringObfuscator.getString(R.string.hello);
6065
```
66+
Or from encrypted variables:
67+
```java
68+
String decrypted = AndroidStringObfuscator.decryptString(encrypted_var);
69+
```
70+
Sample
71+
------
6172

73+
```java
74+
AndroidStringObfuscator.init(this);
75+
76+
// getting encrypted string resources
77+
int stringId = R.string.hello;
78+
79+
String message = getString(stringId);
80+
message += " is ";
81+
message += AndroidStringObfuscator.getString(stringId);
82+
83+
// and secret
84+
String mySecret = "lalilulelo";
85+
86+
message += "\n\nFor Metal Gear lovers:\n\n\"Snake, the password is " + AndroidStringObfuscator.encryptString(mySecret)
87+
+ "\n\n.. or " + AndroidStringObfuscator.decryptString(AndroidStringObfuscator.encryptString(mySecret)) + "\"";
88+
89+
((TextView) findViewById(R.id.example)).setText(message);
90+
```
6291
Gradle Console Output Example
6392
-----------------------------
6493
```
@@ -68,29 +97,32 @@ Gradle Console Output Example
6897
:sample:obfuscator-script - -----------------------------------------------------------------------------
6998
:sample:obfuscator-script - debug variant
7099
:sample:obfuscator-script - SHA1 fingerprint: E1:28:0C:3E:65:91:2E:21:E9:98:2B:58:80:9A:25:3A:F6:88:7D:FF
71-
:sample:obfuscator-script - [StringObfuscato..] - [7CFBFBEE31ABA92..]
100+
:sample:obfuscator-script - [hello world!] - [D1862D9B434D08E..]
72101
:sample:obfuscator-script - -----------------------------------------------------------------------------
73102
:sample:obfuscator-script - v 0.5
74103
:sample:processDebugManifest UP-TO-DATE
75104
...
76105
```
77106

78-
### Possible errors
79-
Missing `~/.android/debug.keystore`. Run your app to generate that file.
107+
108+
#### More information
109+
At first run, if you haven't installed Gradle:
110+
```
111+
...
112+
:sample:obfuscator-script - Downloading https://services.gradle.org/distributions/gradle-2.14.1-all.zip
113+
:sample:obfuscator-script - Unzipping /Users/efraespada/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1-all.zip to /Users/efraespada/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv
114+
:sample:obfuscator-script - Set executable permissions for: /Users/efraespada/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1/bin/gradle
115+
...
116+
```
117+
118+
If `~/.android/debug.keystore` is missing, run your app to generate that file.
80119
```
81120
...
82-
:sample:mergeDebugResources
83-
:sample:initStringObfuscator
84-
:sample:obfuscator-script - -----------------------------------------------------------------------------
85121
:sample:obfuscator-script - debug variant
86122
:sample:obfuscator-script - Missing keystore
87123
:sample:obfuscator-script - SHA1 fingerprint not detected; try params [module] [variant] [optional:sha1]
88-
:sample:obfuscator-script - -----------------------------------------------------------------------------
89-
:sample:obfuscator-script - v 0.5
90-
:sample:processDebugManifest
91124
...
92125
```
93-
94126
License
95127
-------
96128
Copyright 2017 Efraín Espada

androidstringobfuscator/androidstringobfuscator.iml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
8484
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
8585
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
86+
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
8687
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
8788
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8889
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
@@ -93,15 +94,15 @@
9394
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/exposed-instrumentation-api-publish/0.5/jars" />
9495
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/rules/0.5/jars" />
9596
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/runner/0.5/jars" />
96-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.1.0/jars" />
97-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/25.1.0/jars" />
98-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/25.1.0/jars" />
99-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-ui/25.1.0/jars" />
100-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-utils/25.1.0/jars" />
101-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-fragment/25.1.0/jars" />
102-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/25.1.0/jars" />
103-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/25.1.0/jars" />
104-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/25.1.0/jars" />
97+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.1.1/jars" />
98+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/25.1.1/jars" />
99+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/25.1.1/jars" />
100+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-ui/25.1.1/jars" />
101+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-utils/25.1.1/jars" />
102+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-fragment/25.1.1/jars" />
103+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/25.1.1/jars" />
104+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/25.1.1/jars" />
105+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/25.1.1/jars" />
105106
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
106107
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
107108
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
@@ -113,12 +114,13 @@
113114
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
114115
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
115116
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/typedefs.txt" />
117+
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
116118
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
119+
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
117120
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
118121
</content>
119122
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
120123
<orderEntry type="sourceFolder" forTests="false" />
121-
<orderEntry type="library" exported="" name="support-annotations-25.1.0" level="project" />
122124
<orderEntry type="library" exported="" scope="TEST" name="espresso-core-2.2.2" level="project" />
123125
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
124126
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.5" level="project" />
@@ -128,19 +130,19 @@
128130
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation-api-1.2" level="project" />
129131
<orderEntry type="library" exported="" scope="TEST" name="javax.inject-1" level="project" />
130132
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-integration-1.3" level="project" />
131-
<orderEntry type="library" exported="" name="support-compat-25.1.0" level="project" />
132-
<orderEntry type="library" exported="" name="support-fragment-25.1.0" level="project" />
133-
<orderEntry type="library" exported="" name="animated-vector-drawable-25.1.0" level="project" />
134-
<orderEntry type="library" exported="" name="support-v4-25.1.0" level="project" />
133+
<orderEntry type="library" exported="" name="support-v4-25.1.1" level="project" />
134+
<orderEntry type="library" exported="" name="support-compat-25.1.1" level="project" />
135135
<orderEntry type="library" exported="" scope="TEST" name="javawriter-2.1.1" level="project" />
136136
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
137-
<orderEntry type="library" exported="" name="support-core-ui-25.1.0" level="project" />
138-
<orderEntry type="library" exported="" name="support-media-compat-25.1.0" level="project" />
137+
<orderEntry type="library" exported="" name="support-media-compat-25.1.1" level="project" />
138+
<orderEntry type="library" exported="" name="support-core-ui-25.1.1" level="project" />
139139
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
140-
<orderEntry type="library" exported="" name="support-vector-drawable-25.1.0" level="project" />
141-
<orderEntry type="library" exported="" name="appcompat-v7-25.1.0" level="project" />
140+
<orderEntry type="library" exported="" name="appcompat-v7-25.1.1" level="project" />
142141
<orderEntry type="library" exported="" scope="TEST" name="jsr305-2.0.1" level="project" />
143-
<orderEntry type="library" exported="" name="support-core-utils-25.1.0" level="project" />
144-
<orderEntry type="library" exported="" name="android-android-25" level="project" />
142+
<orderEntry type="library" exported="" name="support-annotations-25.1.1" level="project" />
143+
<orderEntry type="library" exported="" name="support-vector-drawable-25.1.1" level="project" />
144+
<orderEntry type="library" exported="" name="support-core-utils-25.1.1" level="project" />
145+
<orderEntry type="library" exported="" name="support-fragment-25.1.1" level="project" />
146+
<orderEntry type="library" exported="" name="animated-vector-drawable-25.1.1" level="project" />
145147
</component>
146148
</module>

androidstringobfuscator/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
22
apply plugin: 'com.github.dcendents.android-maven'
33
apply plugin: 'com.jfrog.bintray'
44

5-
version = "0.2"
5+
version = "0.4"
66

77
android {
88
compileSdkVersion 25
@@ -12,7 +12,7 @@ android {
1212
minSdkVersion 9
1313
targetSdkVersion 25
1414
versionCode 1
15-
versionName "0.2"
15+
versionName "0.4"
1616

1717
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1818

@@ -34,7 +34,7 @@ dependencies {
3434
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
3535
exclude group: 'com.android.support', module: 'support-annotations'
3636
})
37-
compile 'com.android.support:appcompat-v7:25.1.0'
37+
compile 'com.android.support:appcompat-v7:25.1.1'
3838
testCompile 'junit:junit:4.12'
3939
}
4040

@@ -49,7 +49,7 @@ install {
4949
pom {
5050
project {
5151
packaging 'aar'
52-
name 'Simple Android lib to hide strings'
52+
name 'Simple Android library to hide strings'
5353
url siteUrl
5454
// Set your license
5555
licenses {

0 commit comments

Comments
 (0)