Skip to content

Commit

Permalink
⚰️ Drop unused external bcrypt library
Browse files Browse the repository at this point in the history
  • Loading branch information
jemrobinson committed Feb 13, 2024
1 parent bea9ccc commit d0ea90a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 28 deletions.
5 changes: 0 additions & 5 deletions data_safe_haven/functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
alphanumeric,
b64decode,
b64encode,
bcrypt_encode,
bcrypt_salt,
hex_string,
password,
random_letters,
Expand All @@ -29,11 +27,8 @@
__all__ = [
"allowed_dns_lookups",
"alphanumeric",
"as_dict",
"b64decode",
"b64encode",
"bcrypt_encode",
"bcrypt_salt",
"hex_string",
"ordered_private_dns_zones",
"password",
Expand Down
20 changes: 0 additions & 20 deletions data_safe_haven/functions/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions typings/bcrypt/__init__.pyi

This file was deleted.

0 comments on commit d0ea90a

Please sign in to comment.