android hide secrets
Blog post
快速演示顯示在移動應用中隱藏秘密的幾種方式,例如:
為GRADLE_ENV_API_KEY設置API鍵:
$ export GRADLE_ENV_API_KEY= $( echo " api-key-for-gradle-file-from-env " | openssl dgst -binary -sha256 | openssl enc -base64 )
$ echo $GRADLE_ENV_API_KEY
srqGFqMm23R6A7YJbAEmKRuSQ6TWnLq3YNtAWbEoSuE=為JNI_API_KEY設置API鍵:
$ cp -v app/src/main/cpp/api_key.h.example app/src/main/cpp/api_key.h
' app/src/main/cpp/api_key.h.example ' - > ' app/src/main/cpp/api_key.h '現在,編輯文件app/src/main/cpp/api_key.h並查找PALCE持有人ANDROID_HIDE_SECRETS_API_KEY_H ,並用所需的place-the-api-key-here ,也許喜歡:
echo " api-key-for-the-jni-file " | openssl dgst -binary -sha256 | openssl enc -base64
yDbx5R+a6zJ3H76iU9YB9U0GY6DjZ4FiWFb8vCMCdLg=只需啟動您的Android Studio,並像往常一樣為任何其他移動應用程序構建和運行此項目。
該應用程序是一個假人,僅在主屏幕中顯示所有隱藏在代碼中的所有API鍵,只是為了證明我們可以檢索它們。