Ask A Question

Notifications

You’re not receiving notifications from this thread.

Base62 Decoding Short Codes Discussion

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

Reply

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

Reply

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

Reply

Hi Chris!

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

Reply

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

Reply

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?

Reply
Join the discussion
Create an account Log in

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

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

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