Created
January 12, 2018 16:43
-
-
Save simonr-cb/53138f7d3760aea2629b9fb986392583 to your computer and use it in GitHub Desktop.
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
val secret = HMAC_SECRET | |
var keySpec: SecretKeySpec | |
... | |
... | |
val obfuscatedSecretData = Base64.decode(secret, Base64.DEFAULT) | |
val shipFastAPIKeyData = loadShipFastAPIKey(context).toByteArray(Charsets.UTF_8) | |
for (i in 0 until minOf(obfuscatedSecretData.size, shipFastAPIKeyData.size)) { | |
obfuscatedSecretData[i] = (obfuscatedSecretData[i].toInt() xor shipFastAPIKeyData[i].toInt()).toByte() | |
} | |
val obfuscatedSecret = Base64.encode(obfuscatedSecretData, Base64.DEFAULT) | |
keySpec = SecretKeySpec(Base64.decode(obfuscatedSecret, Base64.DEFAULT), "HmacSHA256") | |
... | |
... | |
// Compute the request HMAC using the HMAC SHA-256 algorithm | |
... | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment