Skip to content

Commit fbe895d

Browse files
author
Skip Hovsmith
committed
Merge branch 'release' into 'master'
First release for the dummy app to hide secrets in Android. See merge request criticalblue/marketing/demos/android-hide-secrets!1
2 parents 36c0433 + ed02173 commit fbe895d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1101
-1
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.local/

.idea/codeStyles/Project.xml

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,39 @@ A quick demo to show several ways of hiding secrets in a mobile app, like in:
55
* source code
66
* manifest file
77
* gradle file
8-
* NDK
8+
* JNI/NDK
9+
10+
11+
## SETUP
12+
13+
To set the API key for `GRADLE_ENV_API_KEY`:
14+
15+
```bash
16+
$ export GRADLE_ENV_API_KEY=$(echo "api-key-for-gradle-file-from-env" | openssl dgst -binary -sha256 | openssl enc -base64)
17+
$ echo $GRADLE_ENV_API_KEY
18+
srqGFqMm23R6A7YJbAEmKRuSQ6TWnLq3YNtAWbEoSuE=
19+
```
20+
21+
To set the API key for `JNI_API_KEY`:
22+
23+
```bash
24+
$ cp -v app/src/main/cpp/api_key.h.example app/src/main/cpp/api_key.h
25+
'app/src/main/cpp/api_key.h.example' -> 'app/src/main/cpp/api_key.h'
26+
```
27+
28+
Now edit the file `app/src/main/cpp/api_key.h` and look for the palce holder
29+
`ANDROID_HIDE_SECRETS_API_KEY_H` and replace its dummy value
30+
`place-the-api-key-here` with your desired API key, maybe like:
31+
32+
```bash
33+
echo "api-key-for-the-jni-file" | openssl dgst -binary -sha256 | openssl enc -base64
34+
yDbx5R+a6zJ3H76iU9YB9U0GY6DjZ4FiWFb8vCMCdLg=
35+
```
36+
37+
## RUN
38+
39+
Just start your Android Studio and build and run this project as usual for any
40+
other mobile app.
41+
42+
The app is a dummy one that only shows in the main screen all API keys hidden in
43+
the code, just to prove that we can retrieve them.

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 28
5+
defaultConfig {
6+
applicationId "com.criticalblue.androidhidesecrets"
7+
minSdkVersion 15
8+
targetSdkVersion 28
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
resValue "string", "GRADLE_API_KEY", 'YXBpLWtleS1zdG9yZWQtaW4tZ3JhZGxlLWZpbGUK'
13+
manifestPlaceholders = [GRADLE_API_KEY_PLACEHOLDER: "YXBpLWtleS1wbGFjZWhvbGRlci1pbi1ncmFkbGUtZmlsZQo="]
14+
resValue "string", "GRADLE_ENV_API_KEY", "$System.env.GRADLE_ENV_API_KEY"
15+
externalNativeBuild {
16+
cmake {
17+
cppFlags ""
18+
}
19+
}
20+
}
21+
buildTypes {
22+
release {
23+
debuggable false
24+
minifyEnabled true
25+
shrinkResources true
26+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27+
}
28+
debug {
29+
debuggable true
30+
minifyEnabled true
31+
shrinkResources true
32+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33+
}
34+
}
35+
externalNativeBuild {
36+
cmake {
37+
path "src/main/cpp/CMakeLists.txt"
38+
}
39+
}
40+
}
41+
42+
dependencies {
43+
implementation fileTree(dir: 'libs', include: ['*.jar'])
44+
implementation 'com.android.support:appcompat-v7:28.0.0'
45+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
46+
testImplementation 'junit:junit:4.12'
47+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
48+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
49+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

0 commit comments

Comments
 (0)