Beispiel #1
0
        private string StretchString(string text)
        {
            var pwBytes          = Encoding.UTF8.GetBytes(text);
            var pwBytesStretched = stretchHelper.Stretch(pwBytes);
            var stretchedPW      = Convert.ToBase64String(pwBytesStretched);

            return(stretchedPW);
        }
        public void TestBasic()
        {
            string pw   = "hello world";
            string text = "the man who sold the world";

            var stretchBytes = pwStretch.Stretch(Encoding.UTF8.GetBytes(pw));
            var stretchedPW  = Convert.ToBase64String(stretchBytes);

            encryptHelper.SetKey(stretchedPW);

            var encrypted = encryptHelper.Encrypt(text);

            var decrypted = encryptHelper.Decrypt(encrypted);

            Assert.AreEqual(decrypted, text);
        }