Generate a SHA1-HMAC

Published: 2018-04-12 08:35:04 +0000
Categories: Python,




SHA1-HMAC's are often used by API's (and in tokenisation) as a means to prove control over a shared secret. They allow proof of control without sending the secret over the network.


from hashlib import sha1
import hmac

def createSha1HMAC(signstr,secret):
    ''' Create a SHA1-HMAC of signstr
    hashedver =,signstr,sha1)
    return hashedver.digest().encode('hex')

Usage Example

createSha1HMAC('I Will Sign This String','MySuperS3cr37 key')


HMAC, SHA1, generate, token, mint, create,

Latest Posts

Remotely backing up PFsense Configuration (BASH)
FFMPEG: Converting RMVB to X264 MP4 (BASH)
Recursively print table (print_r equivalent) (LUA)
Bulk Delete Comments from (Self-Hosted) JIRA Issues (Misc)
Add a static entry to the ARP table (BASH)
SSL Cipher Hex codes to Human Readable Names (Misc)
Convert Ascii to Binary (BASH)
Intercepting Outbound DNS Queries (BASH)
Handle Google Verification files within NGinx Configuration (NGinx)
Getting WhatsApp Rich Snippet Previews Working (Misc)

Copyright © 2018 Ben Tasker | Sitemap | Privacy Policy
Available at and snippets.6zdgh5a5e6zpchdz.onion