Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base36 Encode a String?

Tags:

java

python

ruby

I've been looking online, but can't find a solution to this. In Python, Ruby, or Java, how can I base 36 encode the following string: nOrG9Eh0uyeilM8Nnu5pTywj3935kW+5=

like image 599
Bradford Avatar asked Dec 21 '22 13:12

Bradford


2 Answers

Ruby


To base 36:

s.unpack('H*')[0].to_i(16).to_s 36

From base 36:

[s36.to_i(36).to_s(16)].pack 'H*'
like image 199
DigitalRoss Avatar answered Jan 05 '23 23:01

DigitalRoss


Looks like wikipedia has an article on how to do it in python: http://en.wikipedia.org/wiki/Base_36

like image 26
Kaj Avatar answered Jan 05 '23 22:01

Kaj