Example #1
0
        public ActionResult ReadVersionToken(string versionToken)
        {
            var cipherBytes = MachineKeySectionWrapper.HexStringToByteArray(versionToken);
            var plainBytes  = MachineKeySectionWrapper.Decrypt(cipherBytes);
            var version     = Encoding.UTF8.GetString(plainBytes);

            return(this.Json(new { version = version }));
        }
Example #2
0
        public ActionResult Verify(string versionToken)
        {
            var cipherBytes = MachineKeySectionWrapper.HexStringToByteArray(versionToken);
            var plainBytes  = MachineKeySectionWrapper.Decrypt(cipherBytes);
            var plainText   = Encoding.UTF8.GetString(plainBytes);

            ViewBag.Version = plainText;

            return(this.Encrypt(plainText));
        }
Example #3
0
        public ActionResult Encrypt(string plainText)
        {
            ViewBag.PlainText = plainText;

            var plainBytes  = Encoding.UTF8.GetBytes(plainText);
            var cipherBytes = MachineKeySectionWrapper.Encrypt(plainBytes);

            ViewBag.CipherText = MachineKeySectionWrapper.ByteArrayToHexString(cipherBytes);

            return(this.View("Index"));
        }
Example #4
0
        public ActionResult Decrypt(string cipherText)
        {
            ViewBag.CipherText = cipherText;

            var cipherBytes = MachineKeySectionWrapper.HexStringToByteArray(cipherText);
            var plainBytes  = MachineKeySectionWrapper.Decrypt(cipherBytes);

            this.ViewBag.PlainText = Encoding.UTF8.GetString(plainBytes);

            return(this.View("Index"));
        }