Skip to content

Instantly share code, notes, and snippets.

@pquerna
Created July 5, 2011 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pquerna/1065291 to your computer and use it in GitHub Desktop.
Save pquerna/1065291 to your computer and use it in GitHub Desktop.
from socket import gethostname
import time
from cloudkick.ckcrypto import secure_hash
_prefix = "&rh=%s&h=%s" % (secure_hash(4), gethostname())
def txnId(count=0):
global _prefix
t = int(time.time())
a = chr((t >> 24) & 0xFF ) + chr((t >> 16) & 0xFF) + chr((t >> 8) & 0xFF) + chr(t & 0xFF)
return _prefix + "&r=" + secure_hash(8) + "&ts=" + a.encode('base64')[:6] + "&c=" + str(count)
print txnId()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment