Subversion Repositories php-qbpwcf

Rev

Blame | Last modification | View Log | RSS feed

<?php

#使用命名空間qbpwcf
namespace qbpwcf;

#匯入外部套件
include("../allInOne.php");

/*

#提示測試項目
echo "makeJWT and verifyJWT - test 1<br>";

#函式說明:
#建立 JWT 格式的內容
#回傳結果:
#$result["status"],狀態,"true"代表正常;"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["content"],jwt token.
#必填參數:
#$conf["key"],用來驗證簽章的加解密key.
$conf["key"]="dSgVkYp3s6v9y/B?E(H+MbQeThWmZq4t";
#可省略參數:
#$conf["exp"],有效期限要多久,預設為當下加3600秒.
#$conf["exp"]=time()+3600;
#$conf["iat"],簽證時間,預設為當下.
#$conf["iat"]=time();
#$conf["otherBodies"],陣列,其他要放置的payload body內容,key為名稱,value為內容.
#$conf["otherBodies"]=array();
#$conf["base64encodeSig"],是否要base64加密金鑰,預設為"false"不加密,反之"true"代表要加密.
#$conf["base64encodeSig"]="false";
$makeJWT=jwt::makeJWT($conf);
unset($conf);

#如果建立 jwt token 失敗
if($makeJWT["status"]==="false"){

        #印出結果
        var_dump($makeJWT);
        
        #結束執行
        exit;

        }#if end

#印出結果
var_dump($makeJWT);

#函式說明:
#檢查 JWT token 是否合法
#回傳結果:
#$result["status"],"true"代表為正確得JWT token,反之"false"代表不正確得JWT token.
#$result["content"],陣列
#$result["content"]["head"],jwt的head物件.
#$result["content"]["body"],jwt的body物件.
#$result["error"],錯誤訊息陣列.
#必填參數:
#$conf["token"],要驗證的Authorization header內容,亦即"Bearer jwt".
$conf["token"]="Bearer ".$makeJWT["content"];
#$conf["key"],用來驗證簽章的加解密key.
$conf["key"]="dSgVkYp3s6v9y/B?E(H+MbQeThWmZq4t";
#可省略參數:
#$conf["debug"],"false"代表不debug;"true"代表要debug.
#$conf["debug"]="true";
$verifyJWT=jwt::verifyJWT($conf);
unset($conf);

#如果建立 jwt token 失敗
if($verifyJWT["status"]==="false"){

        #印出結果
        var_dump($verifyJWT);
        
        #結束執行
        exit;

        }#if end

#印出結果
var_dump($verifyJWT);

*/

?>