Thursday, December 25, 2014

[Ruby] string to hex, hex to string

String to Hex

require 'digest'
Digest.hexencode(string)
string.unpack('H*').first
Hex to String

[hex].pack('H*')
Credit: http://stackoverflow.com/a/17223012 



No comments:

Clojure has lesser typing error problems than the others well-known dynamic typing languages

Give these snippets a try. // JS function foo () {   bar(1) } # Ruby def foo   bar(1) end ; Clojure (defn foo []    (bar 1)) As yo...