-2

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 3
    Why are you splitting `salt`? Do you know what `str.split` does? It produces a list... – Moses Koledoye Sep 07 '17 at 08:56
  • otherwise its throwing the same error like `TypeError: cannot concatenate 'str' and 'list'`. Can you share solution or this ? –  Sep 07 '17 at 08:58

1 Answers1

0

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)
Nelson
  • 922
  • 1
  • 9
  • 23