Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/hgiasac/go-cookie-signature

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/hgiasac/go-cookie-signature

  • v0.0.0-20240720091011-450ff02eecb2
  • Source
  • Go
  • Socket score

Version published
Created
Source

A cookie signature library which is compatible with cookies signed by https://github.com/tj/node-cookie-signature is written in Go.

Installation

go get github.com/hgiasac/go-cookie-signature

Usage

Functions

secret := []byte("tobiiscool")
signed, err := cookiesignature.Sign("hello", secret)
if err != nil {
  panic(err)
}

log.Println(signed)
// hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI

result, err := cookiesignature.Unsign(signed, secret)
if err != nil {
  panic(err)
}
log.Println(result)
// hello

CookieSignature

CookieSignature encapsules signature methods with reusable secrets. There can be one or more secrets will be stored and verified in a way that ensures the cookie's integrity. Secrets may be rotated by adding new secrets to the front of the secrets array. Cookies that have been signed with old secrets will still be decoded successfully in Unsign, and the newest secret (the first one in the array) will always be used to sign outgoing cookies created in Sign.

cs := cookiesignature.NewCookieSignature([]string{"n3wsecr3t" "olds3cret"})

signed, err := cs.Sign("hello", secret)
if err != nil {
  panic(err)
}

log.Println(signed)
// hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI

result, err := cs.Unsign(signed, secret)
if err != nil {
  panic(err)
}
log.Println(result)

FAQs

Package last updated on 20 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc