Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
removed test for encrypting since it's already covered by test_encrypt_decrypt_cbc_ascii
and there's no way to mock the randomized "iv" value via doctest.testmod
  • Loading branch information
Jtang-1 committed Nov 19, 2024
1 parent ba90659 commit d92e102
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions corehq/motech/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ def b64_aes_cbc_encrypt(message):
AES-encrypt and base64-encode `message` using CBC mode.
Uses Django SECRET_KEY as AES key and generates a random IV.
>>> settings.SECRET_KEY = 'xyzzy'
>>> b64_aes_cbc_encrypt('Around you is a forest.')
# Returns a base64-encoded string of the encrypted message.
"""
if isinstance(settings.SECRET_KEY, bytes):
secret_key_bytes = settings.SECRET_KEY
Expand All @@ -118,7 +113,7 @@ def b64_aes_cbc_decrypt(message):
Uses Django SECRET_KEY as AES key.
>>> settings.SECRET_KEY = 'xyzzy'
>>> b64_aes_cbc_decrypt('...') # Replace with a valid base64-encoded string
>>> b64_aes_cbc_decrypt('6WbQuezOKqp4AMOCoUOndVnAUDL13e0fl3cpxcgHX/AlcPwN4+poaetdjwgikz0F')
'Around you is a forest.'
"""
if isinstance(settings.SECRET_KEY, bytes):
Expand All @@ -136,6 +131,7 @@ def b64_aes_cbc_decrypt(message):
plaintext_bytes = unpad(padded_plaintext_bytes)
return plaintext_bytes.decode('utf8')


# Only needed for migration from ECB to CBC mode.
def reencrypt_ecb_to_cbc_mode(encrypted_text, prefix=None):
"""
Expand Down

0 comments on commit d92e102

Please sign in to comment.