Skip to content

Instantly share code, notes, and snippets.

@allenyang79
Created March 8, 2019 02:46
Show Gist options
  • Save allenyang79/7fcde490ac949dde1dac48594dd5f09f to your computer and use it in GitHub Desktop.
Save allenyang79/7fcde490ac949dde1dac48594dd5f09f to your computer and use it in GitHub Desktop.
a easy way to gen pre-split key
import math
def _get_chunks(chunk_size=4, chars=None):
if not chars:
# chars = list('0123456789') # list('-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz')
chars = list('-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz')
m = chars_size = len(chars)
output_size = 1
while m < chunk_size:
m = m * chars_size
output_size = output_size + 1
interval = float(m) / float(chunk_size)
n = 1
while n < m:
ret = ''
i = int(round(n))
while i > 0:
j = i % chars_size
i = i / chars_size
ret = chars[j] + ret
ret = (chars[0] * (output_size - len(ret))) + ret
yield ret
n += interval
print(list(_get_chunks(64 * 64)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment