[utils] Move base62 to utils
This commit is contained in:
parent
e048d87fc9
commit
81bdc8fdf6
2 changed files with 16 additions and 13 deletions
|
@ -2619,3 +2619,17 @@ def ohdave_rsa_encrypt(data, exponent, modulus):
|
|||
payload = int(binascii.hexlify(data[::-1]), 16)
|
||||
encrypted = pow(payload, exponent, modulus)
|
||||
return '%x' % encrypted
|
||||
|
||||
|
||||
def base_n(num, n, table):
|
||||
if num == 0:
|
||||
return '0'
|
||||
ret = ''
|
||||
while num:
|
||||
ret = table[num % n] + ret
|
||||
num = num // n
|
||||
return ret
|
||||
|
||||
|
||||
def base62(num):
|
||||
return base_n(num, 62, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue