Skip to content

Instantly share code, notes, and snippets.

@turret-io
turret-io / gen_hmac.py
Created September 24, 2014 15:30
Generate HMAC in Python
import hmac, hashlib, json, time, base64
SHARED_SECRET = 'sup3rs3cr3t!!'
def signString(string_to_sign, shared_secret):
return hmac.new(shared_secret, string_to_sign, hashlib.sha512).digest()
if __name__ == '__main__':
payload = {
'name': 'joe smith',
@turret-io
turret-io / gen_hmac.rb
Created September 24, 2014 15:31
Generate HMAC in Ruby
require 'digest'
require 'base64'
require 'cgi'
require 'time'
require 'openssl'
require 'json'
SHARED_SECRET = 'sup3rs3cr3t!!'
def signString(string_to_sign, shared_secret)