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
'.
精彩评论