sha1.js 303 B

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