{"action":"opened","issue":{"url":"https://api.github.com/repos/soulseekah/py-libgfshare/issues/1","labels_url":"https://api.github.com/repos/soulseekah/py-libgfshare/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/soulseekah/py-libgfshare/issues/1/comments","events_url":"https://api.github.com/repos/soulseekah/py-libgfshare/issues/1/events","html_url":"https://github.com/soulseekah/py-libgfshare/issues/1","id":112831041,"number":1,"title":"replacing random with urandom","user":{"login":"hyperbolicTom","id":5808710,"avatar_url":"https://avatars.githubusercontent.com/u/5808710?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperbolicTom","html_url":"https://github.com/hyperbolicTom","followers_url":"https://api.github.com/users/hyperbolicTom/followers","following_url":"https://api.github.com/users/hyperbolicTom/following{/other_user}","gists_url":"https://api.github.com/users/hyperbolicTom/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperbolicTom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperbolicTom/subscriptions","organizations_url":"https://api.github.com/users/hyperbolicTom/orgs","repos_url":"https://api.github.com/users/hyperbolicTom/repos","events_url":"https://api.github.com/users/hyperbolicTom/events{/privacy}","received_events_url":"https://api.github.com/users/hyperbolicTom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-22T15:37:49Z","updated_at":"2015-10-22T15:37:49Z","closed_at":null,"body":"If you happen to replace random with urandom, it's easy to fall into the trap of creating random numbers in the range 0-255. I suggest map( lambda x: x if x != 0 else 1, sharenrs ), just to protect against this. Or at least a comment emphasizing the (1-255) part.\r\n\r\n        # Generate the needed unique share numbers at random\r\n        # 0 shares are NG\r\n        sharenrs = [ord( c ) for c in urandom( sharecount )]\r\n        sharenrs = map( lambda x: x if x != 0 else 1, sharenrs )\r\n        sharenrs = list( map( lambda x: c_ubyte( x ), sharenrs ) )\r\n        sharenrs = ( c_ubyte * len( sharenrs ) )( *sharenrs )\r\n"}}