Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
Examples fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Morselli committed Aug 4, 2016
1 parent 206233c commit 80200d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/Load2.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

// In this example, our input is a JWS string in compact serialization format
// See Signature2.php to know to generate such string
$input = '{"signature":"WXfhjDeRv-PCm-5eIgsTkVkUiCXsVe5FODvYjwKHEofZuzJteiNtiDTuSTOKrbsjXIEDbkP8BvYtToZJikjVvw","protected":"eyJhbGciOiJIUzUxMiJ9","header":{"foo":"bar","123":"ABC"}}';
$input = '{"protected":"eyJhbGciOiJIUzUxMiJ9","header":{"foo":"bar","123":"ABC"},"signature":"WXfhjDeRv-PCm-5eIgsTkVkUiCXsVe5FODvYjwKHEofZuzJteiNtiDTuSTOKrbsjXIEDbkP8BvYtToZJikjVvw"}';

// The payload is detached.
$detached_payload = 'TGl2ZSBsb25nIGFuZCBwcm9zcGVyLg';
$detached_payload = 'Live long and prosper.';

// To verify a JWS, we need a key.
// We create our key object (JWK) using a shared key
Expand Down
3 changes: 1 addition & 2 deletions examples/Signature2.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
$jws = JWSFactory::createJWSWithDetachedPayloadToFlattenedJSON(
'Live long and prosper.',
$key,
$detached_payload,
[
'alg' => 'HS512',
],
Expand All @@ -35,6 +34,6 @@
);

// Now the variable $jws contains a our message signed with the private key.
// The payload is not part of the output. It is stored in the variable $detached_payload (base 64 url safe encoded): TGl2ZSBsb25nIGFuZCBwcm9zcGVyLg
// The payload is not part of the output.
// Please read example Load2.php to know how to load these strings and to verify the signature
// The output contains unprotected headers. That is why it cannot be converted into compact JSON

0 comments on commit 80200d6

Please sign in to comment.