示例#1
0
function Register($data)
{
    $data['password'] = md5($data['password']);
    $data['create_at'] = now();
    $data['update_at'] = now();
    $data['create_ip'] = ip();
    $userid = db_new("user", $data);
    if ($userid) {
        $userinfo = GetInfo($userid);
        $token = Crypt3Des::encrypt(json_encode($userinfo), $GLOBALS['keys']);
        return ErrorCode::CODE("1002", array("token" => urlencode($token)));
    } else {
        return ErrorCode::CODE("1003");
    }
}
示例#2
0
 public static function up_encode($str)
 {
     if (is_array($str) || is_object($str)) {
         $str = json_encode($str);
     }
     $cr = new Crypt3Des(Crypt3DesKey, Crypt3DesIV);
     $str = $cr->encrypt($str);
     $str = str_replace('+', '-', $str);
     $str = str_replace('/', '.', $str);
     $str = str_replace('=', '!', $str);
     return $str;
 }
示例#3
0
 public function register()
 {
     $must = array('verify_code', 'account', 'pwd', 're_pwd');
     $this->check_param($must);
     $this->check_sign();
     extract($this->params);
     do {
         // 判断验证码是否正确
         $this->Table_model->init(T_STORE);
         $crypt3des = new Crypt3Des();
         $store_id = $this->Table_model->record_one(array('verify_code' => $crypt3des->encrypt($verify_code)), array('id'))['id'];
         if ($store_id) {
             $this->Table_model->init(T_STORE_ACCOUNT);
             $account = array('name' => $account, 'pwd' => pass_encrypt($pwd), 'store_id' => $store_id);
             $res = $this->Table_model->records_add($account);
             if ($res['err_num'] == 0) {
                 unset($account['pwd']);
                 $this->st($account, '该商铺添加账号成功');
                 break;
             }
         }
         $this->st(array(), '该商铺添加账号失败', API_NORMAL_ERR);
     } while (0);
     $this->op();
 }
示例#4
0
        die(ErrorCode::CODE("1005"));
    }
    if (inject_check($username)) {
        die(ErrorCode::CODE("1006"));
    }
    $data = array("username" => $username, "password" => $password);
    $info = UserLogin($data);
    die($info);
});
if_post("/Encrypt.json", function () {
    is_api();
    $json = file_get_contents('php://input');
    $jsonarray = json_decode($json, true);
    $userinfo = GetUserinfoJson($jsonarray['token']);
    $md5 = md5($userinfo['username'] . $userinfo['id'] . $userinfo['create_at'] . $userinfo['create_ip'] . $jsonarray['key']);
    $key = Crypt3Des::encrypt($jsonarray['pass'], $md5);
    $md5Key = MD5($key);
    $md5Key = base64_encode($md5Key . $md5Key . $md5Key);
    if (!empty($jsonarray['num'])) {
        die('{"encrypt":"' . substr($md5Key, strlen($md5Key) - $jsonarray['num'], $jsonarray['num']) . '"}');
    } else {
        die('{"encrypt":"' . $md5Key . '"}');
    }
});
if_post("/GetKeyList.json", function () {
    is_api();
    $json = file_get_contents('php://input');
    $jsonarray = json_decode($json, true);
    $userinfo = GetUserinfoJson($jsonarray['token']);
    die(GetUserLinks($userinfo['id']));
});
 public static function encode($string)
 {
     $crypt = new Crypt3Des(Encrypt::$key);
     $encryptStr = $crypt->encrypt($string);
     return $encryptStr;
 }
示例#6
0
/**
 * 3DES加密php程式
 * 
 * @param string $data
 *            需要加密字符串
 * @param string $key
 *            运营商应用密钥
 * @return string $res 加密后的字符串
 */
function do_encrypt($data, $key)
{
    if ($data === '' || !extension_loaded('mcrypt')) {
        return $data;
    }
    if (!defined('_3DES_')) {
        define('_3DES_', 1);
        include_once APPPATH . '/libraries/3des.php';
    }
    $des = new Crypt3Des($key);
    return $des->encrypt($data);
}
示例#7
0
文件: Common.php 项目: helenseo/pay
 /**
  * 產生GPS交易驗證壓碼
  * 
  * @param string $cid
  * @param string $coid
  * @param string $rrn
  * @param string $cuid
  * @param string $amt
  * @param string $rcode
  */
 private function _GetERPC($cid, $coid, $rrn, $cuid, $amt, $rcode)
 {
     $erpc = "";
     $encrypt_data = "%s%s%s%s%s%s";
     // 驗證用的 AMOUNT 需整理成 14 碼
     if (strpos($amt, ".") !== false) {
         $amt = substr($amt, 0, strpos($amt, ".")) . (strlen($amt) - strpos($amt, ".") > 3 ? substr($amt, strpos($amt, ".") + 1, 2) : str_pad(substr($amt, strpos($amt, ".") + 1), 2, "0"));
         $amt = str_pad($amt, 14, "0", STR_PAD_LEFT);
     } else {
         $amt = str_pad($amt, 12, "0", STR_PAD_LEFT) . "00";
         //.PadLeft(14, '0');
     }
     //$amt = "00000000005000";
     $this->encrypt_data = sprintf($encrypt_data, $cid, $coid, $rrn, $cuid, $amt, $rcode);
     $des = new Crypt3Des($this->key, $this->iv);
     $this->base64_encrypt_data = $des->encrypt($this->encrypt_data);
     $erpc = base64_encode(sha1($this->base64_encrypt_data, true));
     return $erpc;
 }