Last active
December 30, 2015 13:43
-
-
Save Virako/bb06f3b5196f8826bad9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hmac | |
from time import time | |
import hashlib | |
shared_secret = b'SHARED' # Change this shared_secret by your shared_secret | |
users = 50000 | |
usersIni = 1 | |
def get_hmac(userId, objType, objId, perm): | |
secret = shared_secret | |
now = 1000*long(time()) | |
message = "%s:%s:%d:%s:%d" % (userId, objType, objId, perm, now) | |
_hmac = hmac.new(str(secret), str(message), hashlib.sha256).hexdigest() | |
khmac = 'khmac:///sha-256;%s/%s' % (_hmac, message) | |
return ','.join([khmac, userId]) | |
hmacs = [] | |
total = 0 | |
ini = time() | |
while total < users: | |
hmacs.append(get_hmac(str(total+usersIni), "AuthEvent", 2, "vote")) | |
total += 1 | |
with open('datas.csv', 'w') as f: | |
f.writelines('\n'.join(hmacs)) | |
print(time() - ini) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment