{"action":"created","issue":{"url":"https://api.github.com/repos/orhan/react-native-openpgp/issues/2","repository_url":"https://api.github.com/repos/orhan/react-native-openpgp","labels_url":"https://api.github.com/repos/orhan/react-native-openpgp/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/orhan/react-native-openpgp/issues/2/comments","events_url":"https://api.github.com/repos/orhan/react-native-openpgp/issues/2/events","html_url":"https://github.com/orhan/react-native-openpgp/issues/2","id":163326986,"number":2,"title":"Fails on crypto/random.js","user":{"login":"sarriaroman","id":370885,"avatar_url":"https://avatars.githubusercontent.com/u/370885?v=3","gravatar_id":"","url":"https://api.github.com/users/sarriaroman","html_url":"https://github.com/sarriaroman","followers_url":"https://api.github.com/users/sarriaroman/followers","following_url":"https://api.github.com/users/sarriaroman/following{/other_user}","gists_url":"https://api.github.com/users/sarriaroman/gists{/gist_id}","starred_url":"https://api.github.com/users/sarriaroman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarriaroman/subscriptions","organizations_url":"https://api.github.com/users/sarriaroman/orgs","repos_url":"https://api.github.com/users/sarriaroman/repos","events_url":"https://api.github.com/users/sarriaroman/events{/privacy}","received_events_url":"https://api.github.com/users/sarriaroman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-01T06:19:03Z","updated_at":"2016-07-01T12:08:55Z","closed_at":null,"body":"When I try to encrypt always fails on random.js because isaacson is undefined.\r\n\r\n```\r\nfor (var i = 0; i < buf.length; i++) {\r\n   buf[i] = Math.floor((isaacson.random() * 255));\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/orhan/react-native-openpgp/issues/comments/229930567","html_url":"https://github.com/orhan/react-native-openpgp/issues/2#issuecomment-229930567","issue_url":"https://api.github.com/repos/orhan/react-native-openpgp/issues/2","id":229930567,"user":{"login":"sarriaroman","id":370885,"avatar_url":"https://avatars.githubusercontent.com/u/370885?v=3","gravatar_id":"","url":"https://api.github.com/users/sarriaroman","html_url":"https://github.com/sarriaroman","followers_url":"https://api.github.com/users/sarriaroman/followers","following_url":"https://api.github.com/users/sarriaroman/following{/other_user}","gists_url":"https://api.github.com/users/sarriaroman/gists{/gist_id}","starred_url":"https://api.github.com/users/sarriaroman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarriaroman/subscriptions","organizations_url":"https://api.github.com/users/sarriaroman/orgs","repos_url":"https://api.github.com/users/sarriaroman/repos","events_url":"https://api.github.com/users/sarriaroman/events{/privacy}","received_events_url":"https://api.github.com/users/sarriaroman/received_events","type":"User","site_admin":false},"created_at":"2016-07-01T12:08:55Z","updated_at":"2016-07-01T12:08:55Z","body":"Yes, I saw the previous issue but doesn't solve the issue. For some reason ```generateRandomValues``` is never being called, so, isaacson is undefined. I made a quick fix in the next method and is working but I'm completely sure about it\r\n\r\n```\r\ngetRandomValues: function(buf) {\r\n    if (!(buf instanceof Uint8Array)) {\r\n      throw new Error('Invalid type: buf not an Uint8Array');\r\n    }\r\n    if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {\r\n      window.crypto.getRandomValues(buf);\r\n    } else if (typeof window !== 'undefined' && typeof window.msCrypto === 'object' && typeof window.msCrypto.getRandomValues === 'function') {\r\n      window.msCrypto.getRandomValues(buf);\r\n    } else if (nodeCrypto) {\r\n      var bytes = nodeCrypto.randomBytes(buf.length);\r\n      buf.set(bytes);\r\n    } else if (this.randomBuffer.buffer) {\r\n      this.randomBuffer.get(buf);\r\n    } else {\r\n        if(!isaacson) {\r\n            isaacson = new Isaac.Isaac();\r\n        }\r\n\r\n      for (var i = 0; i < buf.length; i++) {\r\n        buf[i] = Math.floor((isaacson.random() * 255));\r\n      }\r\n    }\r\n  },\r\n```"}}
{"actor":{"display_login":"sarriaroman"}}