我想使用Ruby和Crypt library編碼一些純文本。然後我想將這個加密的文本(連同其他一些數據)作爲一個ASCII十六進制字符串傳送到一個XML文件中。如何在Ruby中將Blowfish編碼的二進制字符串轉換爲ASCII?
我有下面的代碼片段:
require 'rubygems'
require 'crypt/blowfish'
plain = "This is the plain text"
puts plain
blowfish = Crypt::Blowfish.new("A key up to 56 bytes long")
enc = blowfish.encrypt_block(plain)
puts enc
,輸出:
This is the plain text ????;
我相信我需要調用enc.unpack()
,但我不知道需要解包方法調用的參數是什麼。
那將恢復明文和輸出過,問題是,我相信,請求如何服用含有密文和輸出它的緩衝區。 – animal 2009-04-30 19:28:13