Exemplo n.º 1
0
        public string GetSecretToken()
        {
            Util.Check(_settings.Options.IsSet(RecaptchaOptions.UseSecureToken), "Using secure token with reCapcha is not configured, cannot create token.");
            var sessionId = Guid.NewGuid();
            var timeStamp = (long)(DateTime.UtcNow - UnixEra).TotalMilliseconds;
            var token     = RecaptchaUtil.GenerateSecureToken(sessionId, timeStamp, _encryptionKeyIv);

            return(token);
        }
Exemplo n.º 2
0
 //we allow setting recaptcha service later, at web app config time
 public RecaptchaService(RecaptchaSettings settings)
 {
     Util.Check(settings != null, "Recaptcha settings may not be null.");
     Util.Check(!string.IsNullOrEmpty(settings.SiteSecret), "reCaptcha not configured: SiteSecret may not be empty.");
     Util.Check(!string.IsNullOrEmpty(settings.SiteKey), "reCaptcha not configured: SiteKey may not be empty.");
     _settings = settings;
     if (_settings.Options.IsSet(RecaptchaOptions.UseSecureToken))
     {
         _encryptionKeyIv = RecaptchaUtil.GetEncryptionKey(_settings.SiteSecret);
     }
 } //constructor