cookiesignature

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cookiesignature signs and verifies cookie values using HMAC-SHA256, mirroring the behavior of the npm cookie-signature library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(value, secret string) string

Sign returns value with an HMAC-SHA256 signature appended, in the form "value.signature". The signature is the base64url-encoded HMAC of value keyed by secret, with trailing '=' padding removed, matching the npm cookie-signature library.

func Unsign

func Unsign(signed, secret string) (string, bool)

Unsign verifies a signed value produced by Sign against secret. It returns the original value and true when the signature is valid, or "" and false when the signature does not match or the input is malformed (for example, when it contains no '.' separator). The comparison is performed in constant time.

Types

This section is empty.

Jump to

Keyboard shortcuts

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