1
$\begingroup$

Here's the code:

salt = b'salt123123123'
password = 'password123'
hash_password = argon2.PasswordHasher().hash(password.encode('UTF-8'), salt = salt)

Returns

$argon2id$v=19$m=65536,t=3,p=4$c2FsdDEyMzEyMzEyMw$GJrdl/EO1WTelvwalnJsSc/JcMsS0LGEVsIwcd/xSIU

The salt here is c2FsdDEyMzEyMzEyMw, how can i get back the original salt?

(From c2FsdDEyMzEyMzEyMw -> salt123123123)

$\endgroup$

1 Answer 1

1
$\begingroup$

c2FsdDEyMzEyMzEyMw is encoded with base64 but has its padding chopped off. In Python you can decode it quite easily:

import base64

def b64decode(b64str):
    padding = "=" * (-len(b64str) % 4)
    return base64.decodebytes(f"{b64str}{padding}".encode("ascii"))

print(b64decode("c2FsdDEyMzEyMzEyMw"))

Please note that base64 is not an encryption scheme but a type of encoding.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.