Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Oct 3, 2023 via pnpm

cookie-signature 1.2.1

Sign and unsign cookies
Package summary
Share
0
issues
0
licenses
Package created
15 Oct 2012
Version published
27 Feb 2023
Maintainers
3
Total deps
0
Direct deps
0
License
MIT

Issues

0
This package has no issues

Frequently Asked Questions

What does cookie-signature do?

Cookie-signature is a powerful npm package primarily designed to secure cookies by signing and unsigning them. It boosts the security of cookie-based applications by preventing tampering and making your cookies more secure.

How do you use cookie-signature?

Using cookie-signature is quite simple and straightforward. Firstly, you need to install the package into your project using npm - npm install cookie-signature. Then, you can require the package and use its sign and unsign methods as shown in the example below:

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

// signing a cookie
var val = cookie.sign('hello', 'tobiiscool');
console.log(val);  // outputs: hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI

// unsigning a cookie
var origValue = cookie.unsign(val, 'tobiiscool');
console.log(origValue);  // outputs: hello

// unsigning a cookie with wrong secret returns false
var wrongValue = cookie.unsign(val, 'luna');
console.log(wrongValue);  // outputs: false

In the above code, 'hello' is the value of the cookie and 'tobiiscool' is the secret with which the cookie is signed or unsigned.

Where are the cookie-signature docs?

Unfortunately, there is no separate documentation provided for cookie-signature. Most of the vital information you need to use the package can be found in the readme of the package's GitHub repository. You can view various usage examples and explanations directly on the GitHub repo.