Socket
Socket
Sign inDemoInstall

scmp

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    scmp

safe, constant-time string-comparison


Version published
Weekly downloads
1.3M
increased by0.18%
Maintainers
1
Install size
3.68 kB
Created
Weekly downloads
 

Package description

What is scmp?

The scmp package in npm is a secure, constant-time comparison of strings or buffers. It is primarily used to prevent timing attacks when comparing sensitive data, such as cryptographic hashes or tokens.

What are scmp's main functionalities?

Secure String Comparison

This feature allows for the secure comparison of two strings, ensuring that the time taken to compare is constant, thus preventing timing attacks.

const scmp = require('scmp');
const a = 'not_so_secret';
const b = 'not_so_secret';
console.log(scmp(a, b)); // outputs: true

Secure Buffer Comparison

Similar to string comparison, this feature enables the secure, constant-time comparison of two buffers, which is useful for comparing binary data securely.

const scmp = require('scmp');
const buffer1 = Buffer.from('secret_data');
const buffer2 = Buffer.from('secret_data');
console.log(scmp(buffer1, buffer2)); // outputs: true

Other packages similar to scmp

Readme

Source

scmp

Build Status

Safe, constant-time comparison of strings.

Install

npm install scmp

Why?

To minimize vulnerability against timing attacks.

Examples

var scmp = require('scmp');

var hash      = 'e727d1464ae12436e899a726da5b2f11d8381b26';
var givenHash = 'e727e1b80e448a213b392049888111e1779a52db';

if (scmp(hash, givenHash)) {
  console.log('good hash');
} else {
  console.log('bad hash');
}

Keywords

FAQs

Last updated on 24 Mar 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc