亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Blowfish/CBC/PKCS5Padding 加密和解密數據

使用 Blowfish/CBC/PKCS5Padding 加密和解密數據

C#
慕碼人2483693 2022-06-12 16:23:40
舊版應用程序 (ColdFusion) 正在使用Blowfish/CBC/PKCS5Padding加密。我們如何使用 BouncyCastle 庫加密和解密這些數據?對于其他字段,使用以下命令在 ColdFusion 中加密:encrypt( data, key, 'BLOWFISH', 'HEX')我們使用此代碼BlowfishEngine engine = new BlowfishEngine();PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(engine);cipher.Init(false, new KeyParameter(Convert.FromBase64String(keyString)));byte[] out1 = Hex.Decode(name);byte[] out2 = new byte[cipher.GetOutputSize(out1.Length)];int len2 = cipher.ProcessBytes(out1, 0, out1.Length, out2, 0);cipher.DoFinal(out2, len2);return Encoding.UTF8.GetString(out2);問題是如何解密一些東西,像這樣在 ColdFusion 中加密:encrypt( data, Key, "Blowfish/CBC/PKCS5Padding", "base64", IV )
查看完整描述

1 回答

?
胡說叔叔

TA貢獻1804條經驗 獲得超8個贊

我想到了。如果有人感興趣:


        BlowfishEngine engine = new BlowfishEngine();

        var cipher = new PaddedBufferedBlockCipher( new CbcBlockCipher( engine ), new Pkcs7Padding() );

        StringBuilder result = new StringBuilder();

        cipher.Init( false, new ParametersWithIV( new KeyParameter( Convert.FromBase64String( keyString ) ), System.Text.Encoding.ASCII.GetBytes( IV ) ) );

        byte[] out1 = Convert.FromBase64String( name );

        byte[] out2 = new byte[ cipher.GetOutputSize( out1.Length ) ];

        int len2 = cipher.ProcessBytes( out1, 0, out1.Length, out2, 0 );

        cipher.DoFinal( out2, len2 );

        return Encoding.UTF8.GetString( out2 );


查看完整回答
反對 回復 2022-06-12
  • 1 回答
  • 0 關注
  • 310 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號