예제 #1
0
        protected override byte[] DecodeBytes(byte[] data, SecureString password)
        {
            var key = HashPassword(password, KEY_SIZE);
            var iv = data.Take(IV_SIZE).ToArray();

            var fish = new BlowFish(key) { IV = iv };

            return TrimRightNull(fish.Decrypt_CBC(data.Skip(IV_SIZE).ToArray()));
        }
예제 #2
0
파일: Main.cs 프로젝트: spiridenok/HOP
 public void RoundTripTest()
 {
     Console.WriteLine("Start");
     BlowFish b = new BlowFish("04B915BA43FEB5B6");
     string org_text = "The quick brown fox jumped over the lazy dog.";
     //Console.WriteLine(plainText);
     string cipherText = b.Encrypt_CBC(org_text);
     //Console.WriteLine(cipherText);
     string decoded_text = b.Decrypt_CBC(cipherText);
     //Console.WriteLine(plainText);
     Assert.AreEqual(org_text, decoded_text);
 }
예제 #3
0
파일: Main.cs 프로젝트: spiridenok/HOP
 public void CorruptDecodeTest()
 {
     Console.WriteLine("Start");
     BlowFish b = new BlowFish("04B915BA43FEB5B6");
     string org_text = "The quick brown fox jumped over the lazy dog.";
     string cipherText = b.Encrypt_CBC(org_text);
     System.Text.StringBuilder corrupted_text = new System.Text.StringBuilder(cipherText);
     corrupted_text[3] = 'A';
     corrupted_text[10] = 'B';
     corrupted_text[50] = 'C';
     string decoded_text = b.Decrypt_CBC(corrupted_text.ToString());
     //Console.WriteLine(decoded_text);
     Assert.AreNotEqual(org_text, decoded_text);
     Console.WriteLine(System.Environment.GetEnvironmentVariable("Path"));
 }