sha1.js 284 B

12345678910111213
  1. import crypto from 'crypto';
  2. function sha1(bytes) {
  3. if (Array.isArray(bytes)) {
  4. bytes = Buffer.from(bytes);
  5. } else if (typeof bytes === 'string') {
  6. bytes = Buffer.from(bytes, 'utf8');
  7. }
  8. return crypto.createHash('sha1').update(bytes).digest();
  9. }
  10. export default sha1;