-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Base32 for shorter urls #43
Comments
I'm looking for someone with the skills required to assess this as I'm not good enough with prob / crypto to assess the impact of this. I haven't forget to process it. Sorry for the delay. |
That's ok, I'm not familiar with JS too. |
It seems that sjcl JS doesn't have any base32 codec. |
Actually, we can make the URL even shorter if we turn the scjl result Now, in Python, I know I can convert to and from any base in base 10 from __future__ import division
# symbole table
SYM2VAL = {l: i for i, l in enumerate(string.uppercase.replace("O",
""))}
VAL2SYM = dict(enumerate(string.uppercase.replace("O", "")))
def to_base_10(string, table):
""" Convert from a custom base to base 10 """
i = 0
base = len(table)
for c in string:
i *= base
i += table[c]
return i
def from_base_10(i, table):
""" Convert from a base 10 to a custom base"""
array = []
base = len(table)
if i == 0:
return "A"
while i:
i, value = divmod(i, base)
array.append(table[value])
return ''.join(reversed(array)) So we don't need to install an additional lib. We can port this to JS, 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ if I like 346789abcdefghijklmnopqrtuvwxyABCDEFGHIJKMNPQRTUVWXY because 1, l, L It stills requires people to tell if it's lower case or uppercase, but |
Yes it seems to me that base64 is shorter actually:
|
Yep. Closing. |
Since we have base64-like encoding shorter urls(#42), I perform Crockford's Base32 encoding which is more human readable in case of you write it down.
The text was updated successfully, but these errors were encountered: