Getting error while encrypting the password using salt in Python

37 views Asked by At

I am getting error while encrypting the password using Python. I am explaining the error below.

Error:

Traceback (most recent call last):
  File "password.py", line 60, in <module>
    hashed_password = hashlib.sha512(sword + salt).hexdigest()
TypeError: cannot concatenate 'str' and 'list' objects

My code is given below.

import hashlib
value = "2Y7xk5vrs5DeCcSdinRVKQ=="
salt = value.split()
sword = "subhra1234"
hashed_password = hashlib.sha512(sword + salt).hexdigest()
print(hashed_password)

Here I need to use own salt value and trying to encrypting the password. Please help to resolve this error.

1

There are 1 answers

0
Nelson On BEST ANSWER

Like @MosesKoledoye said, you don't need to call split on the salt:

import hashlib
salt = "2Y7xk5vrs5DeCcSdinRVKQ=="
sword = "subhra1234"
hashed_password = hashlib.sha512(sword + salt).hexdigest()
print(hashed_password)