gojwe

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 4 Imported by: 0

README

gojwe

JWE wrapper for Golang.

Install

go get github.com/prongbang/gojwe

How to use

  • Random Secret Key
openssl rand -hex 32
  • New instance
j := gojwe.New()
  • Generate
payload := map[string]any{
    "exp": 99999999999,
}
key := "bdacaf398071931518f73917cb0c6f04b3a0ab45ee9cbedc258047a8c149a3e1"
accessToken, err := j.Generate(payload, key)
  • Parse
key := "bdacaf398071931518f73917cb0c6f04b3a0ab45ee9cbedc258047a8c149a3e1"
accessToken := "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjk5OTk5OTk5OTk5fQ.rMKkGe6riuLZ3boYiMZsk5xrT7S-7VK6gZmFs1_7kKtVUkpvGatudYI5ZSkwIQ-iJKp2XskCxzn_6fVkCohtUQ"
payload, err := j.Parse(accessToken, key)
  • Verify
key := "bdacaf398071931518f73917cb0c6f04b3a0ab45ee9cbedc258047a8c149a3e1"
accessToken := "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjk5OTk5OTk5OTk5fQ.rMKkGe6riuLZ3boYiMZsk5xrT7S-7VK6gZmFs1_7kKtVUkpvGatudYI5ZSkwIQ-iJKp2XskCxzn_6fVkCohtUQ"
got := j.Verify(accessToken, key)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWEToken

type JWEToken Token

func New

func New() JWEToken

type Token

type Token interface {
	Generate(payload map[string]any, key string) (string, error)
	Verify(token, key string) bool
	Parse(token, key string) (map[string]any, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL