This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
strong-cipher with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Provides access to strong encryption and hashing, both synchronous and asynchronous, using Node's crypto library.
Encrypt will generate a random iv and salt. These values will be prepended to the encrypted value and used during the decryption process. Identical strings will have different encrypted results but decrypt to the same string.
Hash uses HMAC and a random salt generated for the key. This salt is pre-pended to the resulting hash (similar to bcrypt) and helps reduce common brute force hash attacks.
If the password is incorrect, the methods will throw an error so handle as needed.
Asynchronous methods return a Promise.
npm run test or
yarn run test to run tests.
const cipher = require('strong-cipher') cipher('password').encryptSync('some string')
const cipher = require('strong-cipher') cipher('password').hashSync('some string')
const cipher = require('strong-cipher') cipher('password').validHashSync('some string', 'Ome50nWjXGK0PuqFBYywMkykJoCaKEE4BqztT8rr+CkbxDP+EZMCb6vIKgNaGmjU')
const cipher = require('strong-cipher') cipher('password').randomPinSync(6)