Skip to content

Instantly share code, notes, and snippets.

@kouk
Last active December 23, 2015 06:29
Show Gist options
  • Save kouk/6594128 to your computer and use it in GitHub Desktop.
Save kouk/6594128 to your computer and use it in GitHub Desktop.
base58 ID with AES (pyCrypto)
from Crypto.Cipher import AES
from base58 import b58encode
shard = {'id': 5, 'pw': 'myshardpw16bytes'}
id = "%016d-" % shard['id']
id += AES.new('myshardpw16bytes').encrypt("%016d"%1)
assert b58encode(id) == 'FKGJyhKSHVaem5JbQqmBLTcgHzBtp7D3UGZPuPqSB8PN9'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment