1

I am using below code for encrypting password.

from passlib.context import CryptContext

pwd_context = CryptContext(
    schemes=["pbkdf2_sha256"],
    default="pbkdf2_sha256",
    pbkdf2_sha256__default_rounds=30000
 )

 def encrypt_password(password):
    return pwd_context.encrypt(password)


 def check_encrypted_password(password, hashed):
    return pwd_context.verify(password, hashed)

When I call encrypt_password('password') function it will encrypt my password into hash value and give me output as follow..

'$pbkdf2-sha256$30000$X6vVGgNgzFmrlVIq5RyjVA$VGQ5x.yuabpdNMDMNc1S3/umqXMl3605DyjJ/lgXAM0'

The output of encypted password hashed value is too long value. I want to get output in fixed sized like "30 characters or 40 characters". How to get fix sized output.? Can anyone help me to understand this.

Thank You !

Urvi Soni
  • 314
  • 1
  • 2
  • 12
  • Why do you want or expect that output length? – Davis Herring May 30 '19 at 23:48
  • For storing it on database. But It's Okay I did R & D and Understand that we can't reduce hash characters into some length because it's automatically generated. Solved my problem. – Urvi Soni Jun 02 '19 at 15:44

0 Answers0