How to perform Triple DES calculations in Ruby in hexadecimal?

纵饮孤独 提交于 2019-12-03 21:46:10

The key is in hex - if you look at the Java page you pasted you can see that easily by decoding the binary values for the key in the detailed output.

>> des_cbc=OpenSSL::Cipher::Cipher.new("des-ede-cbc")
=> #<OpenSSL::Cipher::Cipher:0x10116ce28>
>> des_cbc.encrypt
=> #<OpenSSL::Cipher::Cipher:0x10116ce28>
>> des_cbc.key="\x23"*8 << "\x45"*8
=> "########EEEEEEEE"
>> des_cbc.update("\x00"*8).unpack('H*')
=> ["3a42d7a1d1c60c40"]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!