Beispiel #1
0
        public void GetAndEncryptInput()
        {
            // Get input
            string input = Console.ReadLine().ToUpper();

            // "Encrypt" it
            string output = encryptionAlgorithm.Encrypt(input);

            // Write output
            Console.WriteLine(output);
        }
        public EncryptionResult Encrypt(byte[] plaintext)
        {
            var encrypted = _cipher.Encrypt(_key.Bytes, plaintext, AssociatedData);

            return(new EncryptionResult
            {
                Alg = _cipher.Algorithm,
                Ciphertext = Convert.ToBase64String(encrypted),
                Kid = _key.Id
            });
        }
Beispiel #3
0
        public string GetString(object value, ISerializeOptions options)
        {
            var returnValue = _decoratedValueConverter.GetString(value, options);

            if (options.ShouldEncrypt)
            {
                returnValue = _encryptionAlgorithm.Encrypt(returnValue);
            }

            return(returnValue);
        }
        public void EncryptTest()
        {
            //Arrange
            string plain  = "hidethegoldinthetreestump";
            string cypher = "bmodzbxdnabekudmuixmmouvif";

            //Act
            string actual = _target.Encrypt(plain);

            //Assert
            Assert.Equal(cypher, actual);
        }
Beispiel #5
0
        public void EncryptTest()
        {
            //Arrange
            string plain  = "paymoremoney";
            string cypher = "lnshdlewmtrw";

            //Act
            string actual = _target.Encrypt(plain);

            //Assert
            Assert.Equal(cypher, actual);
        }
 private void btnEncrypt_Click(object sender, EventArgs e)
 {
     InputText = txtEncryptInputContent.Text;
     Key       = txtKey.Text;
     if (string.IsNullOrEmpty(InputText) || string.IsNullOrEmpty(Key))
     {
         MessageBox.Show("Şifrelemek için metin ve anahtar girmek zorunludur.");
         return;
     }
     algorithm = new VigenereCipher(InputText, Key);
     txtEncryptOutContent.Text = algorithm.Encrypt();
 }
Beispiel #7
0
        public void EncryptTest()
        {
            //Arrange
            string plain  = "meetmeafterthegraduationparty";
            string cypher = "mematrhgautopryetefeterdainat*";

            //Act
            string actual = _target.Encrypt(plain);

            //Assert
            Assert.Equal(cypher, actual);
        }
Beispiel #8
0
        public void EncryptTest()
        {
            //Arrange
            string plain  = "attackpostponeduntiltwoam";
            string cypher = "ttna aptm tsuo aodw coi* knl* pet* ";

            //Act
            string actual = _target.Encrypt(plain);

            //Assert
            Assert.Equal(cypher, actual);
        }
Beispiel #9
0
        public void EncryptTest()
        {
            //Arrange
            string plain  = "meetmeafterthetogaparty";
            string cypher = "phhwphdiwhuwkhwrjdsduwb";

            //Act
            string actual = _target.Encrypt(plain);

            //Assert
            Assert.Equal(cypher, actual);
        }
Beispiel #10
0
        public void EncryptTest()
        {
            //Arrange
            string plain = "abcd";

            //Act
            string cypher = _target.Encrypt(plain);

            //Assert
            Assert.NotEqual(cypher, plain);

            //Act
            string actual = _target.Decrypt(cypher);

            //Assert
            Assert.Equal(plain, actual);
        }
Beispiel #11
0
 public string Encrypt(string input)
 {
     return(encryptor.Encrypt(input));
 }