Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
updated bytes() function to distinguish between python 2/3
Browse files Browse the repository at this point in the history
  • Loading branch information
netson committed Oct 26, 2021
1 parent 8ec7f55 commit 045b588
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
23 changes: 19 additions & 4 deletions ahvl/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
from ahvl.generate.sshhostkey import GenerateSSHHostKey
from ahvl.generate.gpgkey import GenerateGPGKey

# to be able to check the python version/distinguish between p2/p3 bytes() function
import sys

#
# message
#
Expand Down Expand Up @@ -167,19 +170,31 @@ def return_postgresmd5(self, secret, options):

def return_pbkdf2sha256(self, secret, options):
from passlib.hash import pbkdf2_sha256
return pbkdf2_sha256.hash(secret, salt=bytes(self.find_salt(options)))
if sys.version_info.major == 2:
return pbkdf2_sha256.hash(secret, salt=bytes(self.find_salt(options)))
else:
return pbkdf2_sha256.hash(secret, salt=bytes(self.find_salt(options), encoding='utf8'))

def return_pbkdf2sha512(self, secret, options):
from passlib.hash import pbkdf2_sha512
return pbkdf2_sha512.hash(secret, salt=bytes(self.find_salt(options)), rounds=58000)
if sys.version_info.major == 2:
return pbkdf2_sha512.hash(secret, salt=bytes(self.find_salt(options)), rounds=58000)
else:
return pbkdf2_sha512.hash(secret, salt=bytes(self.find_salt(options), encoding='utf8'), rounds=58000)

def return_argon2(self, secret, options):
from passlib.hash import argon2
return argon2.using(salt=bytes(self.find_salt(options)), rounds=32).hash(secret)
if sys.version_info.major == 2:
return argon2.using(salt=bytes(self.find_salt(options)), rounds=32).hash(secret)
else:
return argon2.using(salt=bytes(self.find_salt(options), encoding='utf8'), rounds=32).hash(secret)

def return_grubpbkdf2sha512(self, secret, options):
from passlib.hash import grub_pbkdf2_sha512
return grub_pbkdf2_sha512.hash(secret, salt=bytes(self.find_salt(options)), rounds=38000)
if sys.version_info.major == 2:
return grub_pbkdf2_sha512.hash(secret, salt=bytes(self.find_salt(options)), rounds=38000)
else:
return grub_pbkdf2_sha512.hash(secret, salt=bytes(self.find_salt(options), encoding='utf8'), rounds=38000)

#
# find salt
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

setup(
name="ahvl",
version="1.2.0",
version="1.2.1",
author="RH Sonnenberg",
author_email="[email protected]",
description="Base libraries for the Ansible HashiCorp Vault Lookup (AHVL) Plugin by Netson",
long_description=long_description,
long_description_content_type="text/markdown",
license='MIT',
url="https://github.com/netson/ahvl",
download_url='https://github.com/netson/ahvl/archive/v1.2.0.tar.gz',
download_url='https://github.com/netson/ahvl/archive/v1.2.1.tar.gz',
packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit 045b588

Please sign in to comment.