diff --git a/app/build.gradle b/app/build.gradle index 59dc70b6..fe1dab94 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -86,6 +86,9 @@ android { variant.resValue "string", "mapbox_key", mapboxKey } def chargepriceKey = env.CHARGEPRICE_API_KEY ?: project.findProperty("CHARGEPRICE_API_KEY") + if (chargepriceKey == null && project.hasProperty("CHARGEPRICE_API_KEY_ENCRYPTED")) { + chargepriceKey = decode(project.findProperty("CHARGEPRICE_API_KEY_ENCRYPTED"), "FmK.d,-f*p+rD+WK!eds") + } if (chargepriceKey != null) { variant.resValue "string", "chargeprice_key", chargepriceKey } @@ -188,3 +191,15 @@ dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1' } + +private static String decode(String s, String key) { + return new String(xorWithKey(s.decodeBase64(), key.getBytes()), "UTF-8"); +} + +private static byte[] xorWithKey(byte[] a, byte[] key) { + byte[] out = new byte[a.length]; + for (int i = 0; i < a.length; i++) { + out[i] = (byte) (a[i] ^ key[i%key.length]); + } + return out; +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 23339e0d..376270d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,4 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official +kotlin.code.style=official \ No newline at end of file