Lines Matching defs:secret
22 * Create new secret.
34 // Valid secret lengths are 80 to 640 bits
36 throw new \Exception('Bad secret length');
38 $secret = '';
52 $secret .= $validChars[ord($rnd[$i]) & 31];
58 return $secret;
62 * Calculate the code, with given secret and point in time.
64 * @param string $secret
69 public function getCode($secret, $timeSlice = null)
75 $secretkey = $this->_base32Decode($secret);
79 // Hash it with users secret key
101 * @param string $secret
107 public function getQRCodeGoogleUrl($name, $secret, $title = null, $params = array())
113 $urlencoded = urlencode('otpauth://totp/'.$name.'?secret='.$secret.'');
124 * @param string $secret
131 public function verifyCode($secret, $code, $discrepancy = 1, $currentTimeSlice = null)
142 $calculatedCode = $this->getCode($secret, $currentTimeSlice + $i);
168 * @param $secret
172 protected function _base32Decode($secret)
174 if (empty($secret)) {
181 $paddingCharCount = substr_count($secret, $base32chars[32]);
188 substr($secret, -($allowedValues[$i])) != str_repeat($base32chars[32], $allowedValues[$i])) {
192 $secret = str_replace('=', '', $secret);
193 $secret = str_split($secret);
195 for ($i = 0; $i < count($secret); $i = $i + 8) {
197 if (!in_array($secret[$i], $base32chars)) {
201 $x .= str_pad(base_convert(@$base32charsFlipped[@$secret[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);