Пример #1
0
 public ActionResult GetPasswordToken()
 {
     try
     {
         PasswordToken token = new PasswordToken
         {
             Rsa           = (RSACryptoServiceProvider)RSACryptoServiceProvider.Create(),
             ChallengeData = Guid.NewGuid().ToString("N").Substring(0, 8)
         };
         var rsa = _randomCodeHelper.CreateObject(RandomCodeNames.PasswordToken, token, TimeSpan.FromMinutes(1));
         var p   = token.Rsa.ExportParameters(false);
         return(Json(new
         {
             Success = true,
             RsaModulus = p.Modulus.ToHexString(),
             RsaExponent = p.Exponent.ToHexString(),
             ChallengeData = rsa.ChallengeData.GetBytesAscii().ToHexString()
         }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new SimpleAjaxResult(ex.Message), JsonRequestBehavior.AllowGet));
     }
 }