You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the existing hash-function based permalinking, there's tension between the desire to deterministically create the same string from the same hash each time, vs. having the hash select only a template string, with the randomized elements being chosen anew each time it's loaded. (See #109, for example.)
But it strikes me that the messages in question are small enough, that it might make sense to just encode the message itself into the permalink. That way, it can be recreated without any dependency on the hash function used, or the lookup implementation.
Python's standard library already has the base64 module, with its urlsafe_b64encode and urlsafe_b64decode functions. Here's how a typical message looks when encoded to URLsafe base64:
>>>frombase64importurlsafe_b64encode, urlsafe_b64decode>>>msg="Put everything in its right place">>>coded=urlsafe_b64encode(msg.encode("utf-8"))
>>>codedb'UHV0IGV2ZXJ5dGhpbmcgaW4gaXRzIHJpZ2h0IHBsYWNl'
The message can easily be reversed back into its text form:
>>>urlsafe_b64decode(coded).decode("utf-8")
'Put everything in its right place'
The longest message in the data, currently, is this one at 263 characters:
I'll mention this again, if you're git-blaming this, don't come slap me personally. This code straight ported from another project and we WILL refactor this in the future. This is a temporary solution. OK I guess you can slap me for porting this as is, but still.
Encoded to base64, it becomes 352 characters, which is long but not unreasonable as a URL length. (Have you seen Google Maps URLs?)
The text was updated successfully, but these errors were encountered:
With the existing hash-function based permalinking, there's tension between the desire to deterministically create the same string from the same hash each time, vs. having the hash select only a template string, with the randomized elements being chosen anew each time it's loaded. (See #109, for example.)
But it strikes me that the messages in question are small enough, that it might make sense to just encode the message itself into the permalink. That way, it can be recreated without any dependency on the hash function used, or the lookup implementation.
Python's standard library already has the
base64
module, with itsurlsafe_b64encode
andurlsafe_b64decode
functions. Here's how a typical message looks when encoded to URLsafe base64:The message can easily be reversed back into its text form:
The longest message in the data, currently, is this one at 263 characters:
Encoded to base64, it becomes 352 characters, which is long but not unreasonable as a URL length. (Have you seen Google Maps URLs?)
The text was updated successfully, but these errors were encountered: