Какую библиотеку лучше всего использовать для BlowFish / DH? - PullRequest
1 голос
/ 26 июня 2011

Какая лучшая библиотека, которую я могу использовать для BlowFish / DH, потому что я использовал BouncyCastle, но похоже, что она не выполняет то, что я хочу, поэтому мне было интересно, есть ли другая библиотека, которую я могу использовать, чтобы она позволяла мне работатьс CFB / DH?Спасибо

А вот мой класс BouncyCastle:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Modes;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Math;


namespace Common.Encryption
{
    public class BlowfishCryptographer
    {
        private bool forEncryption;
        private IBufferedCipher cipher;

        public BlowfishCryptographer(bool forEncryption)
        {
            this.forEncryption = forEncryption;
            cipher = new BufferedBlockCipher(new CfbBlockCipher(new BlowfishEngine(), 64));
            cipher.Init(forEncryption, new ParametersWithIV(new KeyParameter(Encoding.ASCII.GetBytes("DR654dt34trg4UI6")), new byte[8]));
        }
        public void ReInit(byte[] IV,BigInteger pubkey)
        {
            cipher.Init(forEncryption, new ParametersWithIV(new KeyParameter(pubkey.ToByteArrayUnsigned()),IV));
        }
        public byte[] DoFinal()
        {
            return cipher.DoFinal();
        }
        public byte[] DoFinal(byte[] buffer)
        {
           return cipher.DoFinal(buffer);
        }
        public byte[] DoFinal(byte[] buffer, int startIndex, int len)
        {
            return cipher.DoFinal(buffer, startIndex, len);
        }
        public byte[] ProcessBytes(byte[] buffer)
        {
            return cipher.ProcessBytes(buffer);
        }
        public byte[] ProcessBytes(byte[] buffer, int startIndex, int len)
        {
            return cipher.ProcessBytes(buffer, startIndex, len);
        }
        public void   Reset()
        {
            cipher.Reset();
        }
    }
}

1 Ответ

0 голосов
/ 26 июня 2011

Исходный код для реализации довольно легко найти в интернете.

Это то, что вы ищете?

http://www.schneier.com/code/blowfish.cs

...