Skip to content

Commit

Permalink
Merge pull request #80 from KOSASIH/deepsource-transform-37e1b424
Browse files Browse the repository at this point in the history
style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf
  • Loading branch information
KOSASIH authored May 10, 2024
2 parents 4258e25 + 6da95e8 commit 4a47d86
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions security/authentication.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import hashlib
import secrets


class Authentication:
def __init__(self):
self.salt = secrets.token_hex(16)

def generate_password_hash(self, password):
password_hash = hashlib.pbkdf2_hmac('sha256', password.encode(), self.salt.encode(), 100000)
password_hash = hashlib.pbkdf2_hmac(
"sha256", password.encode(), self.salt.encode(), 100000
)
return password_hash.hex()

def verify_password(self, password, password_hash):
password_hash_check = hashlib.pbkdf2_hmac('sha256', password.encode(), self.salt.encode(), 100000)
password_hash_check = hashlib.pbkdf2_hmac(
"sha256", password.encode(), self.salt.encode(), 100000
)
return password_hash_check.hex() == password_hash

0 comments on commit 4a47d86

Please sign in to comment.