public virtual void testEncryptDecrypt256_falseKey() { System.Console.Out.WriteLine("crypt false key"); byte[] plainInput = Encoding.UTF8.GetBytes("Text to Test for Testing from Tester by Testcase" ); KeyGenSHA3 keyGen = new KeyGenSHA3(); string hexKey = keyGen.generateKey(256, "password"); byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey); CryptAES instance = new CryptAES(); byte[] expResult = plainInput; byte[] result = instance.encrypt(plainInput, bKey); hexKey = keyGen.generateKey(256, "passwordFalse"); bKey = CryptobyHelper.hexStringToBytes(hexKey); result = instance.decrypt(result, bKey); Assert.IsFalse(Encoding.UTF8.GetString(expResult).Equals (Encoding.UTF8.GetString(result))); }
public virtual void testGenerateKey_int_String() { System.Console.Out.WriteLine("generate 256bit Key and comparse with given Key"); int keySize = 256; string password = "******"; KeyGenSHA3 instance = new KeyGenSHA3(); string expResult = "e195622d04525e14469076f4175b990a72995ea7c9f379c465670c330b4f8b60"; string result = instance.generateKey(keySize, password); System.Console.Out.WriteLine(result); NUnit.Framework.Assert.AreEqual(expResult, result); }
public virtual void testGenerateKey_int_random_length512() { System.Console.Out.WriteLine("generate random 512bit Key"); int keySize = 512; KeyGenSHA3 instance = new KeyGenSHA3(); int expResult = 512; int result = Encoding.UTF8.GetBytes(instance.generateKey(keySize)).Length * 4; System.Console.Out.WriteLine(result); NUnit.Framework.Assert.AreEqual(expResult, result); }
public virtual void testEncryptDecrypt256() { System.Console.Out.WriteLine("encrypt and decrypt testphrase"); byte[] plainInput = Encoding.UTF8.GetBytes("Text to Test for Testing from Tester by Testcase" ); KeyGenSHA3 keyGen = new KeyGenSHA3(); string hexKey = keyGen.generateKey(256, "password"); byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey); CryptAES instance = new CryptAES(); byte[] expResult = plainInput; byte[] result = instance.encrypt(plainInput, bKey); result = instance.decrypt(result, bKey); Assert.AreEqual(expResult, result); }
public virtual void testEncryptDecrypt256_HugeData() { System.Console.Out.WriteLine("encrypt and decrypt huge Data"); byte[] plainInput = new byte[1000000]; KeyGenSHA3 keyGen = new KeyGenSHA3(); string hexKey = keyGen.generateKey(256, "password"); byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey); CryptAES instance = new CryptAES(); byte[] expResult = plainInput; byte[] result = instance.encrypt(plainInput, bKey); result = instance.decrypt(result, bKey); for (int i = 0; i < 10; i++) { result = instance.encrypt(plainInput, bKey); result = instance.decrypt(result, bKey); } Assert.AreEqual(expResult, result); }
public virtual void testEncryptDecrypt256_CBC() { System.Console.Out.WriteLine("encrypt and decrypt recurring words"); byte[] plainInput = Encoding.UTF8.GetBytes("TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest" ); KeyGenSHA3 keyGen = new KeyGenSHA3(); string hexKey = keyGen.generateKey(256, "password"); byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey); CryptAES instance = new CryptAES(); byte[] expResult = plainInput; byte[] result = instance.encrypt(plainInput, bKey); string resString = CryptobyHelper.bytesToHexStringUpper(result); for (int i = 0; i < resString.Length - 32; i += 32) { Assert.IsFalse(resString.Substring(i, 32).Equals (resString.Substring(i + 32, 32))); } result = instance.decrypt(result, bKey); Assert.AreEqual(expResult, result); }
public virtual void testEncryptDecrypt256_HugeData() { System.Console.Out.WriteLine("encrypt and decrypt huge Data"); byte[] plainInput = new byte[1000000]; KeyGenSHA3 keyGen = new KeyGenSHA3(); string hexKey = keyGen.generateKey(256, "password"); byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey); CryptAES instance = new CryptAES(); byte[] expResult = plainInput; byte[] result = instance.encrypt(plainInput, bKey); result = instance.decrypt(result, bKey); for (int i = 0; i < 10;i++){ result = instance.encrypt(plainInput, bKey); result = instance.decrypt(result, bKey); } Assert.AreEqual(expResult, result); }