Ejemplo n.º 1
0
 public ActionResult Index(HashGenViewModel hashGenViewModel)
 {
     return(View(new HashGenViewModel()
     {
         HashedValue = String.Empty, HashSecret = String.Empty, ValueToBeHashed = String.Empty
     }));
 }
Ejemplo n.º 2
0
        public ActionResult Hash(HashGenViewModel hashGenViewModel)
        {
            if (!String.IsNullOrWhiteSpace(hashGenViewModel.HashSecret) && !String.IsNullOrWhiteSpace(hashGenViewModel.ValueToBeHashed))
            {
                HMACSHA512 hashSvc   = new HMACSHA512(Encoding.Unicode.GetBytes(hashGenViewModel.HashSecret));
                byte[]     hashBytes = hashSvc.ComputeHash(Encoding.Unicode.GetBytes(hashGenViewModel.ValueToBeHashed));
                hashGenViewModel.HashedValue = Convert.ToBase64String(hashBytes);
            }

            return(View("Index", hashGenViewModel));
        }