Ruby java 的这个 MD5 加密在 ruby 中如何操作?

foxzool · March 14, 2012 · Last by hhuai replied at March 14, 2012 · 10461 hits
sendSignMsg=MD5Util.md5Hex(signMsgVal.getBytes("UTF-8")).toUpperCase();


如上述 java 代码,getBytes 应该是返回一个数组,在 ruby 中如何对这个数组进行 md5 加密?

"abc".bytes

不过如果你是要做 MD5 的话,直接用 Digest::MD5.hexdigest "abc" 就可以了,java 的 api 很多无人性的设计...

我觉得 ruby 对应的方法应该是 readbyte http://www.ruby-doc.org/core-1.9.3/IO.html#method-i-readbyte

require 'digest'

sendSignMsg  = Digest::MD5.hexdigest(signMsgVal.encode('utf-8')).upcase

You need to Sign in before reply, if you don't have an account, please Sign up first.