This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in your .bashrc or .zshrc or whatever you're using | |
# make sure you're in the directory where the file is when running this command | |
alias decrypt_secrets='openssl enc -d -aes-256-cbc -in secrets.properties.enc -out secrets.properties' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in your .bashrc or .zshrc or whatever you're using | |
# make sure you're in the directory where the file is when running this command | |
alias encrypt_secrets='openssl enc -aes-256-cbc -salt -in secrets.properties -out secrets.properties.enc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//AndroidManifest.xml | |
<meta-data | |
android:name="com.google.android.geo.API_KEY" | |
android:value="@string/google_maps_key" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// java code | |
... | |
//init the service | |
return new ExpensiveServiceThatMyAppUses.Builder() | |
.initWithKey(BuildConfig.SERVICE_THAT_I_NEED); // use the value here | |
.someConfig(true) | |
.build(); | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://superuser.com/questions/370388/simple-built-in-way-to-encrypt-and-decrypt-a-file-on-a-mac-via-command-line | |
# decrypt binary file.enc | |
openssl enc -d -aes-256-cbc -in secrets.properties.enc -out secrets.properties | |
# decrypt base64-encoded version | |
openssl enc -d -aes-256-cbc -a -in secrets.properties.enc -out secrets.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools"> | |
.... | |
//We want to use google maps in our app | |
<meta-data | |
android:name="com.google.android.geo.API_KEY" | |
android:value="kx23x234x4x234kjfd9845n" /> // DON'T HARDCODE THE VALUE | |
.... | |
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//build.gradle | |
android{ | |
... | |
productFlavors{ | |
staging{ | |
//use in java code | |
buildConfigField "String", "SERVICE_THAT_I_NEED", getProps("service_secret_key") | |
buildConfigField "String", "MY_BACKEND_URL", getProps("my_url") | |
//use in xml, like AndroidManifest.xml | |
resValue "string", "google_maps_key", getProps("google_maps_key") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://superuser.com/questions/370388/simple-built-in-way-to-encrypt-and-decrypt-a-file-on-a-mac-via-command-line | |
# encrypt file.txt to file.enc using 256-bit AES in CBC mode | |
openssl enc -aes-256-cbc -salt -in secrets.properties -out secrets.properties.enc | |
# the same, only the output is base64 encoded for, e.g., e-mail | |
openssl enc -aes-256-cbc -a -salt -in secrets.properties -out secrets.properties.enc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//build.gradle | |
android{ | |
... | |
productFlavors{ | |
staging{ | |
//use in java code | |
buildConfigField "String", "SERVICE_THAT_I_NEED", "s3cr3t_k3y_f0r_hackz0rz_staging" | |
buildConfigField "String", "MY_BACKEND_URL", "https://www.staging-example.com/api" | |
//use in xml, like AndroidManifest.xml | |
resValue "string", "google_maps_key", "5435651423234" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
//Creating an instance of some service that your app relays on, | |
//Twitter, Facebook, Google, etc | |
//This service costs money to use | |
return new ExpensiveServiceThatMyAppUses.Builder() | |
.initWithKey("s3cr3t_k3y_f0r_hackz0rz"); // DON'T HARDCODE THE VALUE | |
.someConfig(true) | |
.build(); | |
... |