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); }
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; }