Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python bcrypt

#!/usr/bin/env python

import bcrypt

passwd = b's$cret12'

salt = bcrypt.gensalt()
hashed = bcrypt.hashpw(passwd, salt)

if bcrypt.checkpw(passwd, hashed):
    print("match")
else:
    print("does not match")
Comment

python bcrypt

# requires pip install bcrypt
import bcrypt

passwd = b's$cret40$'

# generate a random salt default is 12 rounds
salt = bcrypt.gensalt()
# one way hash encryption
hashed = bcrypt.hashpw(passwd, salt)

# print salt and hash passwd
print(salt)
print(hashed)
# output
# b'$2b$12$d3s7Dzm0r1X.xnpUBEB0qe'
# b'$2b$12$d3s7Dzm0r1X.xnpUBEB0qemgMAErbJW7NXDEH3nEmYd5hXpNXRw9y'

# generate a random salt default is 20 rounds
# the more rounds to encrypt the longer the encryption process will take
salt = bcrypt.gensalt(20)
# one way hash encryption
hashed = bcrypt.hashpw(passwd, salt)

# print salt and hash passwd
print(salt)
print(hashed)
# output
# b'$2b$14$fZXSvkUH8cIvMxmAetZy7O'
# b'$2b$14$fZXSvkUH8cIvMxmAetZy7Od42hj0.rOoAtr/3GGjLyDqn.pKPsCRi'
Comment

PREVIOUS NEXT
Code Example
Python :: random string generator python 
Python :: matplotlib show percentage y axis 
Python :: how to make python speak 
Python :: import pyttsx3 
Python :: values of unique from dataframe with count 
Python :: b1-motion tkinter 
Python :: sqlalchemy datetime default now create table 
Python :: how to increase size of graph in jupyter 
Python :: how to get width of an object in pyqt5 
Python :: how to add 2 dates in python 
Python :: pythom datetime now 
Python :: set the root directory when starting jupyter notebooks 
Python :: check if number in range 
Python :: finding the format of an image in cv2 
Python :: how to sort a column with mixed text number 
Python :: scatter plot plotly 
Python :: hide password input tkinter 
Python :: python print no end of line 
Python :: python file name from absolute path 
Python :: how to delete records in pandas before a certain date 
Python :: python open folder in explorer 
Python :: stringbuilder python 
Python :: find nth root of m using python 
Python :: python ssh library 
Python :: classes in python with self parameter 
Python :: pyperclip copy paste 
Python :: how to get a row from a dataframe in python 
Python :: Incorrect number of bindings supplied. The current statement uses 1, and there are 3 supplied. 
Python :: python read column data from text file 
Python :: remove blank spaces from a list python 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =