关于MD5和SHA、base加密的ruby代码(适合1.9.2)

MD5加密的ruby代码:

require 'digest/md5'



str = "test"

puts Digest::MD5.new(str).hexdigest


顺便整理一下SHA加密和base加密的ruby代码:


#sha1加密
require 'digest/sha1'  
puts Digest::SHA1.hexdigest('admin')

#base64
require 'base64'  
code = Base64.encode64('admin')  
source = Base64.decode64(code)
puts code
puts source

你可能感兴趣的:(ruby本地开发)