示例#1
0
 protected function authenticate($nonce)
 {
     $NC = "00000001";
     $qop = "auth";
     $cnonce = random_uuid();
     $data1 = $this->_phoneNumber;
     $data1 .= ":";
     $data1 .= $this->_whatsAppServer;
     $data1 .= ":";
     $data1 .= $this->EncryptPassword();
     $data2 = pack('H32', md5($data1));
     $data2 .= ":";
     $data2 .= $nonce;
     $data2 .= ":";
     $data2 .= $cnonce;
     $data3 = "AUTHENTICATE:";
     $data3 .= $this->_whatsAppDigest;
     $data4 = md5($data2);
     $data4 .= ":";
     $data4 .= $nonce;
     $data4 .= ":";
     $data4 .= $NC;
     $data4 .= ":";
     $data4 .= $cnonce;
     $data4 .= ":";
     $data4 .= $qop;
     $data4 .= ":";
     $data4 .= md5($data3);
     $data5 = md5($data4);
     $response = sprintf('username="******",realm="%s",nonce="%s",cnonce="%s",nc=%s,qop=%s,digest-uri="%s",response=%s,charset=utf-8', $this->_phoneNumber, $this->_whatsAppRealm, $nonce, $cnonce, $NC, $qop, $this->_whatsAppDigest, $data5);
     return $response;
 }
 function register($username, $email)
 {
     $userid = random_uuid();
     $query = array('RequestMethod' => 'AddUser', 'UserID' => $userid, 'Name' => $username, 'Email' => $email);
     $response = $this->_rest_post($this->user_service, $query);
     if (element('Success', $response)) {
         return $userid;
     } else {
         return null;
     }
 }
 function reset_password_start($user_id)
 {
     $this->user_validation->clear_validation('password', $user_id);
     $code = random_uuid();
     $this->user_validation->set_code($user_id, 'password', $code);
     $user = $this->simiangrid->get_user($user_id);
     $email = $user['Email'];
     if (!send_email($email, set_message('sg_auth_password_subject', get_site_title()), set_message('sg_auth_password_body', site_url("auth/reset_password/{$code}")))) {
         push_message(set_message('sg_email_fail', $email), 'error');
         return false;
     } else {
         return true;
     }
 }
示例#4
0
 public function _authenticate($nonce, $_NC = '00000001')
 {
     $cnonce = random_uuid();
     $a1 = sprintf('%s:%s:%s', $this->_number, $this->_server, $this->_password);
     if (true) {
         $a1 = pack('H32', md5($a1)) . ':' . $nonce . ':' . $cnonce;
     }
     $a2 = "AUTHENTICATE:" . $this->_Digest_Uri;
     $password = md5($a1) . ':' . $nonce . ':' . $_NC . ':' . $cnonce . ':' . $this->_Qop . ':' . md5($a2);
     $password = md5($password);
     $Response = sprintf('username="******",realm="%s",nonce="%s",cnonce="%s",nc=%s,qop=%s,digest-uri="%s",response=%s,charset=utf-8', $this->_number, $this->_Realm, $nonce, $cnonce, $_NC, $this->_Qop, $this->_Digest_Uri, $password);
     return $Response;
 }