From d0ea90a9db86d45f672a851d1516e07130f21674 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Tue, 13 Feb 2024 10:28:18 +0000 Subject: [PATCH] :coffin: Drop unused external bcrypt library --- data_safe_haven/functions/__init__.py | 5 ----- data_safe_haven/functions/strings.py | 20 -------------------- pyproject.toml | 1 - typings/bcrypt/__init__.pyi | 2 -- 4 files changed, 28 deletions(-) delete mode 100644 typings/bcrypt/__init__.pyi diff --git a/data_safe_haven/functions/__init__.py b/data_safe_haven/functions/__init__.py index 179816e4f6..4c3cdfad93 100644 --- a/data_safe_haven/functions/__init__.py +++ b/data_safe_haven/functions/__init__.py @@ -7,8 +7,6 @@ alphanumeric, b64decode, b64encode, - bcrypt_encode, - bcrypt_salt, hex_string, password, random_letters, @@ -29,11 +27,8 @@ __all__ = [ "allowed_dns_lookups", "alphanumeric", - "as_dict", "b64decode", "b64encode", - "bcrypt_encode", - "bcrypt_salt", "hex_string", "ordered_private_dns_zones", "password", diff --git a/data_safe_haven/functions/strings.py b/data_safe_haven/functions/strings.py index 27089eeaed..d7cc679423 100644 --- a/data_safe_haven/functions/strings.py +++ b/data_safe_haven/functions/strings.py @@ -6,8 +6,6 @@ import uuid from collections.abc import Sequence -import bcrypt - def alphanumeric(input_string: str) -> str: """Strip any characters that are not letters or numbers from a string.""" @@ -26,24 +24,6 @@ def b64encode(input_string: str) -> str: return base64.b64encode(input_string.encode("utf-8")).decode() -def bcrypt_encode(input_string: str, salt: str) -> str: - """ - Use bcrypt to encrypt an input string. - See https://en.wikipedia.org/wiki/Bcrypt#Description for structure. - """ - encrypted_bytes = bcrypt.hashpw(input_string.encode(), salt.encode()) - return encrypted_bytes.decode(encoding="utf-8") - - -def bcrypt_salt() -> str: - """Generate a bcrypt salt as a string. - - Returns: - $algorithm$cost$salt: str - """ - return bcrypt.gensalt().decode() - - def hex_string(length: int) -> str: """Generate a string of 'length' random hexadecimal characters.""" return secrets.token_hex(length) diff --git a/pyproject.toml b/pyproject.toml index 23a2441a4c..90e179c1bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,6 @@ dependencies = [ "azure-storage-blob~=12.15", "azure-storage-file-datalake~=12.10", "azure-storage-file-share~=12.10", - "bcrypt~=4.0", "chevron~=0.14", "chili~=2.1", "cryptography~=41.0", diff --git a/typings/bcrypt/__init__.pyi b/typings/bcrypt/__init__.pyi deleted file mode 100644 index f8cb0e2bae..0000000000 --- a/typings/bcrypt/__init__.pyi +++ /dev/null @@ -1,2 +0,0 @@ -def gensalt(rounds: int = 12, prefix: bytes = b"2b") -> bytes: ... -def hashpw(password: bytes, salt: bytes) -> bytes: ...