예제 #1
0
        private void CompareBlocks(ShaAlg Algorithm)
        {
            if (Algorithm == ShaAlg.SHA256)
            {
                byte[] buffer = new byte[639];
                byte[] hash1  = new byte[32];
                byte[] hash2  = new byte[32];

                using (System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
                    rng.GetBytes(buffer);

                // SHA256 //
                // test digest
                using (VTDev.Projects.CEX.Crypto.Digests.SHA256Digest sha1 = new VTDev.Projects.CEX.Crypto.Digests.SHA256Digest())
                    hash1 = sha1.ComputeHash(buffer);

                using (System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256Managed.Create())
                    hash2 = sha.ComputeHash(buffer);

                if (!Compare.AreEqual(hash1, hash2))
                {
                    throw new Exception("SHA512 hash is not equal!");
                }
            }
            else
            {
                // SHA512 //
                byte[] hash1  = new byte[64];
                byte[] hash2  = new byte[64];
                byte[] buffer = new byte[377];

                using (System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
                    rng.GetBytes(buffer);

                // test digest
                using (VTDev.Projects.CEX.Crypto.Digests.SHA512Digest sha2 = new VTDev.Projects.CEX.Crypto.Digests.SHA512Digest())
                    hash1 = sha2.ComputeHash(buffer);

                using (System.Security.Cryptography.SHA512 sha = System.Security.Cryptography.SHA512Managed.Create())
                    hash2 = sha.ComputeHash(buffer);

                if (!Compare.AreEqual(hash1, hash2))
                {
                    throw new Exception("SHA256 hash is not equal!");
                }
            }
        }
예제 #2
0
        private void CompareBlocks(ShaAlg Algorithm)
        {
            if (Algorithm == ShaAlg.SHA256)
            {
                byte[] buffer = new byte[639];
                byte[] hash1 = new byte[32];
                byte[] hash2 = new byte[32];

                using (System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
                    rng.GetBytes(buffer);

                // SHA256 //
                // test digest
                using (VTDev.Projects.CEX.Crypto.Digests.SHA256Digest sha1 = new VTDev.Projects.CEX.Crypto.Digests.SHA256Digest())
                    hash1 = sha1.ComputeHash(buffer);

                using (System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256Managed.Create())
                    hash2 = sha.ComputeHash(buffer);

                if (!Compare.AreEqual(hash1, hash2))
                    throw new Exception("SHA512 hash is not equal!");
            }
            else
            {
                // SHA512 //
                byte[] hash1 = new byte[64];
                byte[] hash2 = new byte[64];
                byte[] buffer = new byte[377];

                using (System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
                    rng.GetBytes(buffer);

                // test digest
                using (VTDev.Projects.CEX.Crypto.Digests.SHA512Digest sha2 = new VTDev.Projects.CEX.Crypto.Digests.SHA512Digest())
                    hash1 = sha2.ComputeHash(buffer);

                using (System.Security.Cryptography.SHA512 sha = System.Security.Cryptography.SHA512Managed.Create())
                    hash2 = sha.ComputeHash(buffer);

                if (!Compare.AreEqual(hash1, hash2))
                    throw new Exception("SHA256 hash is not equal!");
            }
        }
예제 #3
0
 public SHAEquality(ShaAlg Engine)
 {
     this.Implementation = Engine;
 }
예제 #4
0
 public SHAEquality(ShaAlg Engine)
 {
     this.Implementation = Engine;
 }