a zip code crypto-currency system good for red ONLY

sha1.js 579B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. var crypto = require('crypto');
  3. function sha1(bytes) {
  4. if (typeof Buffer.from === 'function') {
  5. // Modern Buffer API
  6. if (Array.isArray(bytes)) {
  7. bytes = Buffer.from(bytes);
  8. } else if (typeof bytes === 'string') {
  9. bytes = Buffer.from(bytes, 'utf8');
  10. }
  11. } else {
  12. // Pre-v4 Buffer API
  13. if (Array.isArray(bytes)) {
  14. bytes = new Buffer(bytes);
  15. } else if (typeof bytes === 'string') {
  16. bytes = new Buffer(bytes, 'utf8');
  17. }
  18. }
  19. return crypto.createHash('sha1').update(bytes).digest();
  20. }
  21. module.exports = sha1;