From 5c7bddb8ab21ca4da8a7b27fc932ca540596d706 Mon Sep 17 00:00:00 2001 From: valorisa Date: Sun, 14 Jul 2024 08:50:44 +0200 Subject: [PATCH] Update How_to_generate_an_bcrypt_hash.md Added a softer way for macOS --- How_to_generate_an_bcrypt_hash.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/How_to_generate_an_bcrypt_hash.md b/How_to_generate_an_bcrypt_hash.md index 46cb2275..31c7696a 100644 --- a/How_to_generate_an_bcrypt_hash.md +++ b/How_to_generate_an_bcrypt_hash.md @@ -59,6 +59,16 @@ pip3 install bcrypt # If you got externally-managed-environment error pip3 install bcrypt --break-system-packages ``` +Alternatively (for macOS), a softer way recommended, instead of --break-system-packages + +```bash +~ % python3 -m venv path/to/venv +~ % source path/to/venv/bin/activate +(venv) ~ % python3 -m pip install --upgrade pip +(venv) ~ % python3 -c "import bcrypt; password = b'XXXXXXXXX'; assert len(password) < 72, 'Password must be less than 72 bytes due to bcrypt limitation'; hashed = bcrypt.hashpw(password, bcrypt.gensalt()); print(f'The hashed password is: {hashed.decode()}'); docker_interpolation = hashed.decode().replace('$', '$$'); print(f'The hashed password for a Docker env is: {docker_interpolation}')" # or python if you run this on Windows. CHANGE your_password_here BY YOUR PASSWORD +The hashed password is: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +The hashed password for a Docker env is: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +``` ## Generating bcrypt hash from the command line You can use the following one-liner command to generate a bcrypt hash directly in the cmd/ terminal: