New Discussion

Notifications

You’re not receiving notifications from this thread.

Base62 Decoding Short Codes Discussion

6
General

Intresting, I had the same requirement so I created this gem https://github.com/xiaohui-zhangxh/xencoder , it can encode/decode interger to BaseX and prevent it to be decoded without seed

How nice to discover ".reverse.each_char.with_index"... much cleaner than the implementation that I was working on!

Thank you very much for all of your work! You are my teacher!

Also, I think I have a better implementation of the decoding algorithm (since ** is a costly operation):
def self.decode(string)
number = 0

string.each_char.with_index do |char, index|
  number = ALPHABET.index(char)  + number * BASE
end

number

end

Hi Chris!

What commands are you using to replace words in selection?
Thx in advance!

i use ".reverse.each_char.with_index"...

Hey buddy!

I mean at 00:25 Chris selecting word "encode" and changing it live to "decode" using some sort of selection.

Any idea what hotkeys he use?

Thank you very much for all of your work!

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 88,834+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.