ronomon / crypto-async

Fast, reliable cipher, hash and hmac methods executed in Node's threadpool for multi-core throughput.
MIT License
174 stars 15 forks source link

How to easily use this package? #2

Closed vincentLiuxiang closed 7 years ago

vincentLiuxiang commented 7 years ago

hi @jorangreef how can i very easily to use this package?

when i use node.js native crypto it is very clear:

const crypto = require('crypto');
const hash = crypto.createHash('SHA256');
hash.update('hello world');
console.log('@@',hash.digest('hex'));

how can i get the same result via crypto-async?

jorangreef commented 7 years ago

Thanks for the feedback @vincentLiuxiang.

Easy-to-use methods have just been added with https://github.com/jorangreef/crypto-async/commit/ab9e605ce66549d97315be069e2dd5f2bd8936f9.

The README has been updated with examples of these new methods.

For example, to hash asynchronously across multiple cores with crypto-async:

var cryptoAsync = require('crypto-async');
cryptoAsync.hash('SHA256', new Buffer('hello world'),
  function(error, hash) {
    if (error) throw error;
    console.log(hash.toString('hex'));
  }
);
vincentLiuxiang commented 7 years ago

thanks @jorangreef