Skip to content

Get hash content using hmac in Python

Advertisements
import hmac
import hashlib
import codecs


# Hash a given content using hmac.
def hash_content_using_hmac(given_content, given_password):
  return hmac.new(codecs.encode(given_password), codecs.encode(given_content), hashlib.sha256).hexdigest()


def main():
    # Hash a given content using hmac
    print(hash_content_using_hmac("Poopcode!", "pwd"))


main()

See also  PHP code snippet - How to separate test database in laravel unit test?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.