PHP code example of syruppay / jose
1. Go to this page and download the library: Download syruppay/jose library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
syruppay / jose example snippets
//COMPOSER의 autoload
$baseDir = "";
pap_sample", "exp":1300819380, "isSample":true}';
//SyrupPay 발급 iss
$iss = 'sample';
//SyrupPay 발급 sing 키 (HmacSha256 기준)
$key = '12345678901234561234567890123456';
/*
* JWS header 규격
* JoseHeaderSpec::ALG : signature algorithm. 아래 Supported JOSE encryption algorithms 참조
*/
$jose = new syruppay_jose_Jose();
$jwsToken = $jose->configuration(
syruppay_jose_JoseBuilders::JsonSignatureCompactSerializationBuilder()
->header(new syruppay_jose_JoseHeader(
array(JOSE_HEADER_ALG => JWA_HS256,
JOSE_HEADER_TYP => 'JWT',
JOSE_HEADER_KID => $iss)))
->payload($payload)
->key($key)
)->serialization();
var_dump($jwsToken);
$jose = new syruppay_jose_Jose();
$claims = $jose->configuration(
syruppay_jose_JoseBuilders::compactDeserializationBuilder()
->serializedSource($jweToken)
->key($key)
)->deserialization();
var_dump($claims);
php
//COMPOSER의 autoload
$baseDir = "";
ppap_sample", "exp":1300819380, "isSample":true}';
//SyrupPay 발급 iss
$iss = 'sample';
//SyrupPay 발급 암복호화 키 (AES256 KeyWrap 기준)
$key = '12345678901234561234567890123456';
/*
* JWE header 규격
* JoseHeaderSpec::ALG : key wrap encryption algorithm. 아래 Supported JOSE encryption algorithms 참조
* JoseHeaderSpec::ENC : content encryption algorithm. 아래 Supported JOSE encryption algorithms 참조
*/
$jose = new syruppay_jose_Jose();
$jweToken = $jose->configuration(
syruppay_jose_JoseBuilders::JsonEncryptionCompactSerializationBuilder()
->header(new syruppay_jose_JoseHeader(
array(JOSE_HEADER_ALG => JWA_A256KW,
JOSE_HEADER_ENG => JWA_A128CBC_HS256,
JOSE_HEADER_KID => $iss)))
->payload($payload)
->key($key)
)->serialization();
var_dump($jweToken);
$jose = new syruppay_jose_Jose();
$payload = $jose->configuration(
syruppay_jose_JoseBuilders::compactDeserializationBuilder()
->serializedSource($jweToken)
->key($key)
)->deserialization();
var_dump($payload);