Swift implementation of JSON Web Token.
CocoaPods is the recommended installation method.
pod 'JSONWebToken'
import JWT
JWT.encode(["my": "payload"], .HS256("secret"))
JWT.decode("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w")
The library supports validating the following claims:
- Issuer (
iss
) Claim - Expiration Time (
exp
) Claim - Not Before (
nbf
) Claim - Issued At (
iat
) Claim - Audience (
aud
) Claim
This library supports the following algorithms:
- None - Unsecured JWTs
- HS256 - HMAC using SHA-256 hash algorithm (default)
Support for HS384 and HS512 can be found in the algorithms-hs
branch which depends on an unreleased version of CryptoSwift. It can be installed via:
pod 'JSONWebToken', :git => 'https://github.com/kylef/JSONWebToken.swift.git', :branch => 'algorithms-hs'
pod 'CryptoSwift', :head
JSONWebToken is licensed under the BSD license. See LICENSE for more info.