public void FeistelTest()
        {
            Enkripsi en = new Enkripsi();
            Dekripsi de = new Dekripsi();

            byte[] b = System.Text.Encoding.ASCII.GetBytes("Mata Kuliah Kriptografi.");
            String k = "12345678";
            en.generateAllInternalKey(k);
            de.generateAllInternalKey(k);

            CollectionAssert.AreEqual(b, de.feistelDecipher(en.feistel(b,en.internalKey),de.internalKey));
        }
Exemple #2
0
 public byte[] decrypt()
 {
     Dekripsi dekripsi = new Dekripsi();
     int blockTotal = cipher.Length / key.Length;
     plain = new byte[cipher.Length];
     for (int i = 0; i < blockTotal; i++)
     {
         byte[] blockCipher = new byte[key.Length];
         for (int j = 0; j < key.Length; j++)
         {
             blockCipher[j] = cipher[i * key.Length + j];
         }
         blockCipher = dekripsi.decrypt(blockCipher, Encoding.ASCII.GetBytes(key));
         for (int j = 0; j < key.Length; j++)
         {
             this.plain[i * key.Length + j] = blockCipher[j];
         }
     }
     return this.plain;
 }
 public void TransposeSentenceTest()
 {
     Enkripsi en = new Enkripsi();
     Dekripsi de = new Dekripsi();
     byte[] b = System.Text.Encoding.ASCII.GetBytes("Mata Kuliah Kriptografi.");
     CollectionAssert.AreEqual(b, de.transpose(en.transpose(b)));
 }
 public void TransposeOneCharTest()
 {
     //
     // TODO: Add test logic here
     //
     Dekripsi de = new Dekripsi();
     Enkripsi en = new Enkripsi();
     byte[] b = System.Text.Encoding.ASCII.GetBytes("a");
     //Assert.AreEqual(b[0],c[0]);
     CollectionAssert.AreEqual(b,de.transpose(en.transpose(b)));
 }
 public void OverallTest()
 {
     Enkripsi en = new Enkripsi();
     Dekripsi de = new Dekripsi();
 }
 public void TransposeTwoCharTest()
 {
     Enkripsi en = new Enkripsi();
     Dekripsi de = new Dekripsi();
     byte[] b = System.Text.Encoding.ASCII.GetBytes("ab");
     CollectionAssert.AreEqual(b,de.transpose(en.transpose(b)));
 }