pwt

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccordPayloadType

func AccordPayloadType[T any](record token.PayloadType, value T) bool

func GetPayload

func GetPayload[T any](pwt *PWT, key string) (T, error)

func IsAlreadySetAnotherTypeErr

func IsAlreadySetAnotherTypeErr(err error) bool

func IsInvalidHeaderErr

func IsInvalidHeaderErr(err error) bool

func IsInvalidPayloadKeyErr

func IsInvalidPayloadKeyErr(err error) bool

func IsInvalidPayloadLengthErr

func IsInvalidPayloadLengthErr(err error) bool

func IsInvalidPayloadTypeErr

func IsInvalidPayloadTypeErr(err error) bool

func IsInvalidSignatureErr

func IsInvalidSignatureErr(err error) bool

func MakeECPrivateKeyToPem

func MakeECPrivateKeyToPem(pk *ecdsa.PrivateKey) ([]byte, error)

func MakeECPublicKeyToPem

func MakeECPublicKeyToPem(pk *ecdsa.PublicKey) ([]byte, error)

func MakeEd25519PrivateKeyToPem

func MakeEd25519PrivateKeyToPem(pk ed25519.PrivateKey) ([]byte, error)

func MakeEd25519PublicKeyToPem

func MakeEd25519PublicKeyToPem(pk ed25519.PublicKey) ([]byte, error)

func NewEcdsaKey

func NewEcdsaKey(curve elliptic.Curve) (*ecdsa.PrivateKey, error)

func NewEcdsaKeyFromSeed

func NewEcdsaKeyFromSeed(curve elliptic.Curve, seed []byte) (*ecdsa.PrivateKey, error)

func NewEd25519Key

func NewEd25519Key() (ed25519.PublicKey, ed25519.PrivateKey, error)

func NewEd25519KeyFromSeed

func NewEd25519KeyFromSeed(seed []byte) (ed25519.PublicKey, ed25519.PrivateKey, error)

func SetPayload

func SetPayload[T any](pwt *PWT, key string, value T) error

Types

type PWT

type PWT struct {
	// contains filtered or unexported fields
}

func From

func From(token *token.Token) *PWT

func Import

func Import(data string) (*PWT, error)

func New

func New() *PWT

func (*PWT) Export

func (p *PWT) Export() (string, error)

func (*PWT) SetAlgorithm

func (p *PWT) SetAlgorithm(sign token.SignatureAlgorithm, hash token.HashAlgorithm) *PWT

func (*PWT) SetType

func (p *PWT) SetType(tokenType token.Type) *PWT

func (*PWT) Sign

func (p *PWT) Sign(secret []byte) (string, error)

func (*PWT) Verify

func (p *PWT) Verify(secret []byte) error

Jump to

Keyboard shortcuts

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