JSPM

secure-compare-native

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 59
  • Score
    100M100P100Q67476F
  • License MIT

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

Package Exports

  • secure-compare-native

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (secure-compare-native) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.