请问ruby中如何对字符串进行sha256加密
高洛峰
高洛峰 2017-04-24 16:00:37
0
1
1099

我的代码是这样的

#sha256加密
if arg_0 == "sha256" && arg_1 == "en"
then enc = OpenSSL::Digest::SHA256.digest(arg_2)
p File.join(enc)
puts File.join(enc)
puts File.join(enc).to_i(16)
puts enc.to_i(16)
end

请问为什么输出是这样的

G:Ruby_pojpoj_1>ruby sha256.rb sha en admin
"x8CivxE5xB5Ax04x15xBDxE9bxBDMxEEx15xDFxB1gxA9xC8sxFCKxB8xA8x
1Fo*xB4HxA9x18"
�iv��A��M���g��s�K��o*�H�
0
0

我实际想要是结果是这种

8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918

请问应该怎么写?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
左手右手慢动作

Is it ruby? The grammar doesn’t feel very similar

If it is ruby, try the following code using irb

require 'digest'
Digest::SHA256.hexdigest 'message' 

Please refer to http://ruby-doc.org/stdlib-2.1.0/libdoc/digest/rdoc/Digest.html

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!