Tạo và ký JSON Web Token HS256 từ một payload và secret, hoàn toàn trong trình duyệt của bạn.
Cách dùng Tạo JWT
Chỉnh payload dưới dạng một đối tượng JSON.
Nhập secret HS256 của bạn.
Tạo và sao chép token đã ký.
A JWT generator that builds and signs JSON Web Tokens from your payload and secret, entirely in your browser using the Web Crypto API. It pairs with the JWT decoder, which inspects an existing token.
A JWT has three parts separated by dots: a header, a payload of claims, and a signature, each Base64url encoded. The signature is what makes the token trustworthy: it proves the payload has not been altered and was issued by someone who holds the secret.
This tool signs with HS256, that is HMAC using SHA-256, the most common symmetric JWT algorithm. The same secret both signs and verifies the token, so it must be kept private on the server.
For HS256, use a long, random secret. A short or guessable secret undermines the whole token, since anyone who guesses it can mint valid tokens of their own.
An important point about JWTs: the payload is only encoded, not encrypted. Anyone with the token can read its claims by Base64-decoding them, so never put passwords or sensitive data in a JWT. The signature stops tampering, it does not provide secrecy.
Because signing happens locally, your secret and payload never leave your device. Even so, avoid pasting real production secrets on a shared or public computer.
Câu hỏi thường gặp
HS256 (HMAC với SHA-256), thuật toán JWT đối xứng phổ biến nhất, được ký trong trình duyệt của bạn bằng Web Crypto API.
Không. Việc ký diễn ra hoàn toàn trong trình duyệt của bạn, nên secret và payload không bao giờ rời khỏi thiết bị. Tuy vậy, hãy tránh secret sản xuất thật trên máy dùng chung.
Có, dùng công cụ giải mã JWT để kiểm tra header và payload của một token hiện có.
Nhúng công cụ này
Thêm công cụ này vào trang web của riêng bạn. Sao chép đoạn mã bên dưới; nó tự động cập nhật.
<iframe src="https://monu.tools/embed/vi/jwt-generator" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>Công cụ liên quan
Tìm kiếm và tra cứu các mã trạng thái HTTP và ý nghĩa của chúng, từ 1xx đến 5xx.
Chuyển một tệp .env sang JSON và JSON trở lại .env, theo cả hai chiều, hoàn toàn trong trình duyệt của bạn.
Tạo một HMAC cho một thông điệp và khóa secret bằng SHA-1, SHA-256, SHA-384 hoặc SHA-512, trong trình duyệt của bạn.
Băm một mật khẩu bằng bcrypt và xác minh một mật khẩu so với một hash bcrypt, hoàn toàn trong trình duyệt của bạn.