-- 创造无限可能

jwt创建密码错误:Key provided is shorter than 256 bits, only 240 bits provided

2022-11-04 19:42:05
691 人浏览 7 人点赞
有用,点赞支持一下

背景

$configuration = Configuration::forSymmetricSigner(
    // You may use any HMAC variations (256, 384, and 512)
    new Sha256(),
    // replace the value below with a key of your own!
    InMemory::base64Encoded('YWFhc0pOU0RLSkJITktKU0RiamhrMTJiM2Joa211')
    // You may also override the JOSE encoder/decoder if needed by providing extra arguments here
);

使用jwt生成秘密的时候,报错Key provided is shorter than 256 bits, only 240 bits provided

问题分析

使用InMemory::base64Encoded时密钥少了四位字符,导致生成的密钥长度只有240