Tag: 河豚

在ruby中使用Blowfish加密字符串会返回比php中的相同进程更短的字符串

这让我很困惑。 当我尝试使用以下输入来加密带有Blowfish的字符串时:key =“some key”input =“input string” 我得到以下结果: ruby: [“79af8c8ee9220bde”] php: 79af8c8ee9220bdec2d1c9cfca7b13c6 我将从php应用程序接收字符串,所以我需要让这两个同步,但我不明白为什么php字符串会更长。 我错过了什么? php代码: php > require_once ‘Crypt/Blowfish.php’; php > $input = “input string”; php > $key = “some key”; php > $crypt = new Crypt_Blowfish($key); php > echo bin2hex($crypt->encrypt($input)); 79af8c8ee9220bdec2d1c9cfca7b13c6 ruby代码: irb(main):001:0> require ‘rubygems’ => true irb(main):002:0> require ‘crypt/blowfish’ => true irb(main):003:0> input = […]

ruby河豚的最后数字差异

我有一些来自API提供商的testdata密钥/文本/加密,现在我正在尝试使用下面的函数产生相同的加密结果,但我的结果会从241位数的最后16位中提供的结果转移。 你有什么想法,原因是什么? 我确信,’bf-ecb’是正确的模式,并尝试使用url编码,但到目前为止还没有成功。 require ‘openssl’ def encrypt(key, data) cipher = OpenSSL::Cipher::Cipher.new(‘bf-ecb’).send(:encrypt) cipher.key = key result = cipher.update(data) << cipher.final hexed = '' result.each_byte { |c| hexed << '%02x' % c } hexed.upcase end UPDATE 还尝试解密示例结果导致OpenSSL :: Cipher :: CipherError“bad decrypt”

无法在Ruby中创建(AS3)兼容的河豚字符串

我正在使用Ruby来尝试加密一个字符串,该字符串将存储在数据库中并由Flash / Actionscript应用程序读取/解密。 该应用程序使用此blowfish实现 。 我尝试了openssl和crypt / blowfish创建兼容字符串的方法。 两者都不匹配,也不匹配Flash应用程序所期望的。 我从哪里开始这个工作? irb(main):001:0> require ‘openssl’ => true irb(main):002:0> require ‘crypt/blowfish’ => true irb(main):007:0> require ‘base64’ => true irb(main):003:0> key = “foo” => “foo” irb(main):004:0> plain = “some string” => “some string” irb(main):005:0> blowfish = Crypt::Blowfish.new(key) => irb(main):006:0> enc = blowfish.encrypt_block(plain) => “\xF5\xAFB\x12=\xB9\xDB\f” irb(main):008:0> Base64.encode64(enc) => “9a9CEj252ww=\n” # […]