Tabnine Logo For Javascript
crypto
Code IndexAdd Tabnine to your IDE (free)

How to use crypto

Best JavaScript code snippets using crypto(Showing top 15 results out of 5,067)

origin: clinicjs/node-clinic

function hash (filename, cb) {
 const sha = crypto.createHash('sha512')
 sha.update('clinic\n')
 fs.createReadStream(filename)
  .on('data', data => sha.update(data))
  .on('end', () => cb(null, sha.digest()))
  .on('error', cb)
}
origin: moleculerjs/moleculer

transporterReceive(next) {
      return (cmd, data, s) => {
        const decrypter = iv ? crypto.createDecipheriv(algorithm, password, iv) : crypto.createDecipher(algorithm, password);
        const res = Buffer.concat([decrypter.update(data), decrypter.final()]);
        return next(cmd, res, s);
      };
    }
origin: shen100/mili

const hmacSHA1 = (key: string, data: string) => {
  // hmac.digest([encoding])
  // If encoding is provided a string is returned; otherwise a Buffer is returned;
  return crypto.createHmac('sha1', key).update(data).digest().toString('base64');
}
origin: parse-community/parse-server

// Returns a new random hex string of the given even size.
function randomHexString(size) {
 if (size === 0) {
  throw new Error('Zero-length randomHexString is useless.');
 }

 if (size % 2 !== 0) {
  throw new Error('randomHexString size must be divisible by 2.');
 }

 return (0, _crypto.randomBytes)(size / 2).toString('hex');
}
origin: parse-community/parse-server

constructor(mongoDatabaseURI = _defaults.default.DefaultMongoURI, mongoOptions = {}, fileKey = undefined) {
  super();
  this._databaseURI = mongoDatabaseURI;
  this._algorithm = 'aes-256-gcm';
  this._fileKey = fileKey !== undefined ? crypto.createHash('sha256').update(String(fileKey)).digest('base64').substr(0, 32) : null;
  const defaultMongoOptions = {
   useNewUrlParser: true,
   useUnifiedTopology: true
  };
  this._mongoOptions = Object.assign(defaultMongoOptions, mongoOptions);
 }
origin: remoteinterview/zero

var getPageID = function(path) {
 return require("crypto")
  .createHash("sha1")
  .update(path)
  .digest("hex");
}
origin: cube-js/cube.js

fileHash(file) {
  return new Promise((resolve, reject) => {
   const hash = crypto.createHash('sha1');
   const stream = fs.createReadStream(file);
   stream.on('error', err => reject(err));
   stream.on('data', chunk => hash.update(chunk));
   stream.on('end', () => resolve(hash.digest('hex')));
  });
 }
origin: remoteinterview/zero

const sha1 = path =>
 new Promise((resolve, reject) => {
  const hash = crypto.createHash("sha1");
  const rs = fs.createReadStream(path);
  rs.on("error", reject);
  rs.on("data", chunk => hash.update(chunk));
  rs.on("end", () => resolve(hash.digest("hex")));
 })
origin: parse-community/parse-server

function getAppSecretPath(authData, options = {}) {
 const appSecret = options.appSecret;
 if (!appSecret) {
  return '';
 }
 const appsecret_proof = crypto
  .createHmac('sha256', appSecret)
  .update(authData.access_token)
  .digest('hex');

 return `&appsecret_proof=${appsecret_proof}`;
}
origin: remoteinterview/zero

function sha1(data) {
 return crypto
  .createHash("sha1")
  .update(data, "binary")
  .digest("hex");
}
origin: remoteinterview/zero

function sha1(data) {
 return crypto
  .createHash("sha1")
  .update(data, "binary")
  .digest("hex");
}
origin: remoteinterview/zero

function sha1(data) {
 return crypto
  .createHash("sha1")
  .update(data, "binary")
  .digest("hex");
}
origin: remoteinterview/zero

function sha1(data) {
 return crypto
  .createHash("sha1")
  .update(data, "binary")
  .digest("hex");
}
origin: remoteinterview/zero

var getPageID = function(path) {
 return require("crypto")
  .createHash("sha1")
  .update(path)
  .digest("hex");
}
origin: parse-community/parse-server

function getAppSecretPath(authData, options = {}) {
 const appSecret = options.appSecret;

 if (!appSecret) {
  return '';
 }

 const appsecret_proof = crypto.createHmac('sha256', appSecret).update(authData.access_token).digest('hex');
 return `&appsecret_proof=${appsecret_proof}`;
}
crypto

Most used crypto functions

  • Hash.update
  • Hash.digest
  • createHash
  • randomBytes
  • Hmac.digest
  • createHmac,
  • Cipher.final,
  • Cipher.update,
  • Decipher.update,
  • Decipher.final,
  • createCipheriv,
  • createCipher,
  • createDecipheriv,
  • createDecipher,
  • pbkdf2,
  • publicEncrypt,
  • privateDecrypt,
  • pbkdf2Sync,
  • DecipherGCM.final

Popular in JavaScript

  • ms
    Tiny millisecond conversion utility
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • q
    A library for promises (CommonJS/Promises/A,B,D)
  • aws-sdk
    AWS SDK for JavaScript
  • semver
    The semantic version parser used by npm.
  • ws
    Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js
  • qs
    A querystring parser that supports nesting and arrays, with a depth limit
  • async
    Higher-order functions and common patterns for asynchronous code
  • fs
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now