News for hackers. Stuff that matters.
Re:Create unique long URL's out of A's by jolmg on Thursday August 20, 2020 @10:31PM (#24231387)
If the point is to lengthen, they could just encode the URL instead of saving it and returning a key. That way it'd be stateless. Something like:

  $ ruby -pe '$_.gsub!(/./) {|c| ("%08b" % c.ord).tr("01", "Aa") }' <<< http://google.com
  AaaAaAAAAaaaAaAAAaaaAaAAAaaaAAAAAAaaaAaAAAaAaaaaAAaAaaaaAaaAAaaaAaaAaaaaAaaAaaaaAaaAAaaaAaaAaaAAAaaAAaAaAAaAaaaAAaaAAAaaAaaAaaaaAaaAaaAa
Then to decode:

  $ ruby -pe '$_.gsub!(/.{8}/) {|s| s.tr("Aa", "01").to_i(2).chr }' <<< AaaAaAAAAaaaAaAAAaaaAaAAAaaaAAAAAAaaaAaAAAaAaaaaAAaAaaaaAaaAAaaaAaaAaaaaAaaAaaaaAaaAAaaaAaaAaaAAAaaAAaAaAAaAaaaAAaaAAAaaAaaAaaaaAaaAaaAa
  http://google.com
EDIT: Wow. I hadn't noticed that HN got rid of the horizontal scrolling behaviour for indented text. It's funny that I kind of miss it in this case.

There are no comments on this comment yet.