开发者

ASCII85 BASE64 Encoding in Ruby

I'm referring to http://www.codinghorror.com/blog/2005/10/equipping-our-ascii-armor.html but I'm getting dr开发者_开发百科astically different results.

Does anyone know how to duplicate his blog post examples in Ruby?


You can generate a random UUID the uuidtools gem and output it as a hex string or an integer. The library also supports generating random strings:

require 'rubygems'
require 'uuidtools'

uuid = UUIDTools::UUID.random_create
puts uuid.to_s
puts uuid.to_i

puts SecureRandom.hex
puts SecureRandom.base64

There's an existing StackOverflow post which discusses converting a number (use to_i) to ASCII 85 in Ruby.

I also found Amp::Encoding::Base85 which you can use with the raw output from uuidtools'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜