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.

33 lines
1012 B

  1. try {
  2. this['Module'] = Module;
  3. Module.test;
  4. } catch(e) {
  5. this['Module'] = Module = {};
  6. }
  7. Module['preRun'] = Module['preRun'] || [];
  8. Module['preRun'].push(function(){
  9. var randombyte = null;
  10. try {
  11. function randombyte_standard() {
  12. var buf = new Int8Array(1);
  13. window.crypto.getRandomValues(buf);
  14. return buf[0];
  15. }
  16. randombyte_standard();
  17. randombyte = randombyte_standard;
  18. } catch (e) {
  19. try {
  20. var crypto = require('crypto');
  21. function randombyte_node() {
  22. return crypto.randomBytes(1)[0];
  23. }
  24. randombyte_node();
  25. randombyte = randombyte_node;
  26. } catch(e) { }
  27. }
  28. FS.init();
  29. var devFolder = FS.findObject('/dev') ||
  30. Module['FS_createFolder']('/', 'dev', true, true);
  31. Module['FS_createDevice'](devFolder, 'random', randombyte);
  32. Module['FS_createDevice'](devFolder, 'urandom', randombyte);
  33. });