IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
738B

  1. //
  2. // Copyright (C) Stanislaw Adaszewski, 2020
  3. // Contact: s.adaszewski@gmail.com
  4. // Website: https://adared.ch/wba
  5. // License: GNU Affero General Public License, Version 3
  6. //
  7. function detectHashes(obj) {
  8. let Q = [ obj ];
  9. let matches = {};
  10. while (Q.length > 0) {
  11. let item = Q.pop();
  12. if (!item)
  13. continue;
  14. if (typeof(item) === 'string') {
  15. // use regexes
  16. let rx = /[a-f0-9]{32}\+[0-9]+/g;
  17. for (let m = rx.exec(item); m; m = rx.exec(item))
  18. matches[m[0]] = true;
  19. } else if (typeof(item) === 'object') {
  20. Object.keys(item).map(k => Q.push(item[k]));
  21. }
  22. }
  23. matches = Object.keys(matches);
  24. return matches;
  25. }
  26. export default detectHashes;