Skip to content

Instantly share code, notes, and snippets.

@SavvyGuard
Created August 20, 2014 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SavvyGuard/9b043ef15345a5fd7780 to your computer and use it in GitHub Desktop.
Save SavvyGuard/9b043ef15345a5fd7780 to your computer and use it in GitHub Desktop.
openx price decryption
# The incoming encrypted price is unpadded websafe base64 encoded of length 38
# This is obtained from base64 encoding the encrypted price, and *then*
# websafe base64 encoding the already encoded encrypted price.
encrypted_price_base64_wsbase64 = 'SjpvRwAB4kB7jEpgW5IA8p73ew9ic6VZpFsPnA'
# We first add padding
encrypted_price_base64_wsbase64_padded = 'SjpvRwAB4kB7jEpgW5IA8p73ew9ic6VZpFsPnA=='
# We decode the web safe base64 encoding
encrypted_price_base64_padded = base64.b64decode(encrypted_price_base64_wsbase64_padded, "-_")
# encrypted_price_base64_padded = 'J:oG\x00\x01\xe2@{\x8cJ`[\x92\x00\xf2\x9e\xf7{\x0fbs\xa5Y\xa4[\x0f\x9c'
# This is python formatted hex string of size 28. \x is an escape meaning the next two characters
# are hex digits and count as 1 character
# The result is a concatenation of a 16-byte initialization vector, 8 bytes of ciphertext,
# and a 4-byte integrity signature
init_vector = 'J:oG\x00\x01\xe2@{\x8cJ`[\x92\x00\xf2'
cipher = '\x9e\xf7{\x0fbs\xa5Y'
integrity = '\xa4[\x0f\x9c'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment