Exemplo n.º 1
0
 static SimpleStringCipher()
 {
     DefaultPassPhrase      = "gsKnGZ041HLL4IM8";
     DefaultInitVectorBytes = Encoding.ASCII.GetBytes("jkE49230Tf093b42");
     DefaultSalt            = Encoding.ASCII.GetBytes("hgt!16kl");
     Instance = new SimpleStringCipher();
 }
        public void Should_Be_Able_To_Change_InitVector_And_Key()
        {
            const string initVectorString = "1234BCHF9876skd*";
            const string myKey = "84ncpaKMC_!TuAna";
            const string plainText = "This is a plain text!";

            var cipher = new SimpleStringCipher
            {
                InitVectorBytes = Encoding.ASCII.GetBytes(initVectorString)
            };

            var enryptedText = cipher.Encrypt(plainText, myKey);
            cipher.Decrypt(enryptedText, myKey).ShouldBe(plainText);
        }