0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

plunkerでjwt その2

Last updated at Posted at 2022-10-20

概要

plunkerでjwtを検証してみた。
jsrsasignを使ってみた。

検証したjwt

  • 出所
    wikiペディア

  • 全体
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI

  • タイプ
    HS256

  • キー
    secretkey

  • ヘッダー
    {
    "alg": "HS256",
    "typ": "JWT"
    }

  • ペイロード
    {
    "loggedInAs": "admin",
    "iat": 1422779638
    }

  • シグニチャー
    gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI

サンプルコード


var out = document.getElementById('out');

function run() {
  var sJWT = KJUR.jws.JWS.sign(null, '{"alg":"HS256","typ":"JWT"}', '{"loggedInAs":"admin","iat":1422779638}', {"utf8": "secretkey"});
  out.value = sJWT;

}

実行結果

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI

成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?