Password Hashing with SHA-256

  • Share this:

Code introduction


This function hashes a password using the SHA-256 algorithm from the hashlib module, and returns the hexadecimal hash value.


Technology Stack : hashlib

Code Type : Password hash function

Code Difficulty : Intermediate


                
                    
import os
import sys
import datetime
import hashlib
import json
import re
import random

def hash_password(password):
    """
    This function hashes a password using SHA-256 algorithm from the hashlib module.
    """
    return hashlib.sha256(password.encode()).hexdigest()                
              
Tags: