From fdfa382c5429a21f4f28a72c344f83c0d76c1ee3 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Wed, 16 Aug 2023 12:01:52 +0100 Subject: [PATCH 1/2] refactor(ciphers): Delete base32 algorithm --- ciphers/base32.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 ciphers/base32.py diff --git a/ciphers/base32.py b/ciphers/base32.py deleted file mode 100644 index fee53ccaf0c4..000000000000 --- a/ciphers/base32.py +++ /dev/null @@ -1,42 +0,0 @@ -import base64 - - -def base32_encode(string: str) -> bytes: - """ - Encodes a given string to base32, returning a bytes-like object - >>> base32_encode("Hello World!") - b'JBSWY3DPEBLW64TMMQQQ====' - >>> base32_encode("123456") - b'GEZDGNBVGY======' - >>> base32_encode("some long complex string") - b'ONXW2ZJANRXW4ZZAMNXW24DMMV4CA43UOJUW4ZY=' - """ - - # encoded the input (we need a bytes like object) - # then, b32encoded the bytes-like object - return base64.b32encode(string.encode("utf-8")) - - -def base32_decode(encoded_bytes: bytes) -> str: - """ - Decodes a given bytes-like object to a string, returning a string - >>> base32_decode(b'JBSWY3DPEBLW64TMMQQQ====') - 'Hello World!' - >>> base32_decode(b'GEZDGNBVGY======') - '123456' - >>> base32_decode(b'ONXW2ZJANRXW4ZZAMNXW24DMMV4CA43UOJUW4ZY=') - 'some long complex string' - """ - - # decode the bytes from base32 - # then, decode the bytes-like object to return as a string - return base64.b32decode(encoded_bytes).decode("utf-8") - - -if __name__ == "__main__": - test = "Hello World!" - encoded = base32_encode(test) - print(encoded) - - decoded = base32_decode(encoded) - print(decoded) From 3d29aa65bae3a5c5bf47771f5a86d232692b314f Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Wed, 16 Aug 2023 11:02:08 +0000 Subject: [PATCH 2/2] updating DIRECTORY.md --- DIRECTORY.md | 1 - 1 file changed, 1 deletion(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 8d1567465fbc..c7f23cbae91e 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -83,7 +83,6 @@ * [Autokey](ciphers/autokey.py) * [Baconian Cipher](ciphers/baconian_cipher.py) * [Base16](ciphers/base16.py) - * [Base32](ciphers/base32.py) * [Base64](ciphers/base64.py) * [Base85](ciphers/base85.py) * [Beaufort Cipher](ciphers/beaufort_cipher.py)