Example #1
0
 public static byte[] Sha1Digest(this byte[] bytes)
 {
     Org.BouncyCastle.Crypto.Digests.Sha1Digest myHash = new Org.BouncyCastle.Crypto.Digests.Sha1Digest();
     myHash.BlockUpdate(bytes, 0, bytes.Length);
     byte[] compArr = new byte[myHash.GetDigestSize()];
     myHash.DoFinal(compArr, 0);
     return(compArr);
 }
 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);
 }
Example #3
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;
 }