secure-compare-native
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

secure-compare-native

Constant-time safe comparison using Node.js native crypto.timingSafeEqual.

Installation

npm install secure-compare-native

Usage

Strings:

const { secureCompare } = require("secure-compare-native");
 
secureCompare("abc", "abc"); // true
secureCompare("hello", "abc"); // false

Buffers:

const { secureCompareBuffer } = require("secure-compare-native");
 
const buff1 = Buffer.from("abc");
const buff2 = Buffer.from("hello");
 
secureCompareBuffer(buff1, buff1); // true
secureCompareBuffer(buff2, buff1); // false

Performance

  • secureCompare is about twice slower than secure-compare on Node v12.
  • secureCompareBuffer is fast when you compare buffers.

License

MIT.

Package Sidebar

Install

npm i secure-compare-native

Weekly Downloads

27

Version

1.0.3

License

MIT

Unpacked Size

5.69 kB

Total Files

6

Last publish

Collaborators

  • pongo