Socket
Socket
Sign inDemoInstall

cookie-signature

Package Overview
Dependencies
0
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

cookie-signature

Sign and unsign cookies

    1.2.1latest
    GitHub
    npm

Version published
Maintainers
3
Weekly downloads
22,278,652
decreased by-15.51%

Weekly downloads

Package description

What is cookie-signature?

The cookie-signature package is used to sign and unsign values using a secret key, typically for use in cookie values to prevent tampering. It provides a simple API for signing and verifying strings.

What are cookie-signature's main functionalities?

Sign

This feature allows you to sign a value using a secret key. The result is a signed value that can be used in a cookie or other transport method. The signature is appended to the value with a 's:' prefix.

"signature = require('cookie-signature');\nsignedValue = signature.sign('value', 'secret');"

Unsign

This feature allows you to unsign a previously signed value using the same secret key. If the signature is valid, the original value is returned. If the signature is invalid, a false value is returned, indicating potential tampering.

"signature = require('cookie-signature');\nunsignedValue = signature.unsign('signedValue', 'secret');"

Other packages similar to cookie-signature

Readme

Source

Sign and unsign cookies.

Example

var cookie = require('cookie-signature');

var val = cookie.sign('hello', 'tobiiscool');
val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI');

var val = cookie.sign('hello', 'tobiiscool');
cookie.unsign(val, 'tobiiscool').should.equal('hello');
cookie.unsign(val, 'luna').should.be.false;

License

MIT.

See LICENSE file for details.

Keywords

FAQs

Last updated on 27 Feb 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc