public static byte[] CalculateDigest(string algorithm, byte[] input)
        {
            IDigest digest = new Org.BouncyCastle.Crypto.Digests.MD5Digest();

            digest.BlockUpdate(input, 0, input.Length);
            return(DoFinal(digest));
        }
Beispiel #2
0
 public void InitaliseHandshakeHash(bool legacy)
 {
     if (legacy)
     {
         _VerifyHandshakeSHA1 = new Org.BouncyCastle.Crypto.Digests.Sha1Digest();
         _VerifyHandshakeMD5 = new Org.BouncyCastle.Crypto.Digests.MD5Digest();
     }
     else
         _VerifyHandshake = new Org.BouncyCastle.Crypto.Digests.Sha256Digest();
 }
 public void InitaliseHandshakeHash(bool legacy)
 {
     if (legacy)
     {
         _VerifyHandshakeSHA1 = new Org.BouncyCastle.Crypto.Digests.Sha1Digest();
         _VerifyHandshakeMD5  = new Org.BouncyCastle.Crypto.Digests.MD5Digest();
     }
     else
     {
         _VerifyHandshake = new Org.BouncyCastle.Crypto.Digests.Sha256Digest();
     }
 }
 public byte[] GetHash()
 {
     byte[] handshakeHash;
     if (_VerifyHandshake == null)
     {
         IDigest sha1 = new Org.BouncyCastle.Crypto.Digests.Sha1Digest(_VerifyHandshakeSHA1);
         IDigest md5  = new Org.BouncyCastle.Crypto.Digests.MD5Digest(_VerifyHandshakeMD5);
         handshakeHash = new byte[sha1.GetDigestSize() + md5.GetDigestSize()];
         md5.DoFinal(handshakeHash, 0);
         sha1.DoFinal(handshakeHash, md5.GetDigestSize());
     }
     else
     {
         IDigest hash = new Org.BouncyCastle.Crypto.Digests.Sha256Digest((Org.BouncyCastle.Crypto.Digests.Sha256Digest)_VerifyHandshake);
         handshakeHash = new byte[hash.GetDigestSize()];
         hash.DoFinal(handshakeHash, 0);
     }
     return(handshakeHash);
 }
Beispiel #5
0
 public byte[] GetHash()
 {
     byte[] handshakeHash;
     if (_VerifyHandshake == null)
     {
         IDigest sha1 = new Org.BouncyCastle.Crypto.Digests.Sha1Digest(_VerifyHandshakeSHA1);
         IDigest md5 = new Org.BouncyCastle.Crypto.Digests.MD5Digest(_VerifyHandshakeMD5);
         handshakeHash = new byte[sha1.GetDigestSize() + md5.GetDigestSize()];
         md5.DoFinal(handshakeHash, 0);
         sha1.DoFinal(handshakeHash, md5.GetDigestSize());
     }
     else
     {
         IDigest hash = new Org.BouncyCastle.Crypto.Digests.Sha256Digest((Org.BouncyCastle.Crypto.Digests.Sha256Digest)_VerifyHandshake);
         handshakeHash = new byte[hash.GetDigestSize()];
         hash.DoFinal(handshakeHash, 0);
     }
     return handshakeHash;
 }