{"id":17815608,"url":"https://github.com/asnelt/derandom","last_synced_at":"2025-03-17T23:30:57.799Z","repository":{"id":28591703,"uuid":"32109902","full_name":"asnelt/derandom","owner":"asnelt","description":"Android pseudo random number predictor","archived":false,"fork":false,"pushed_at":"2024-07-17T20:43:46.000Z","size":3870,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-07-18T00:58:31.732Z","etag":null,"topics":["android-device","java","linear-congruential-generator","mersenne-twister","prng","pseudo-random-generator"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asnelt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-12T23:52:40.000Z","updated_at":"2024-07-17T20:43:49.000Z","dependencies_parsed_at":"2022-08-17T23:55:27.441Z","dependency_job_id":null,"html_url":"https://github.com/asnelt/derandom","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asnelt%2Fderandom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asnelt%2Fderandom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asnelt%2Fderandom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asnelt%2Fderandom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asnelt","download_url":"https://codeload.github.com/asnelt/derandom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221703010,"owners_count":16866463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-device","java","linear-congruential-generator","mersenne-twister","prng","pseudo-random-generator"],"created_at":"2024-10-27T16:13:48.728Z","updated_at":"2024-10-27T16:13:49.375Z","avatar_url":"https://github.com/asnelt.png","language":"Java","readme":"Derandom\n========\n\nPredicts pseudo random numbers based on a sequence of observed numbers.\n\n\nUsage\n-----\n\nEnter a sequence of numbers that you obtained from a pseudo random number\ngenerator like, for instance, the Java standard pseudo random number\ngenerator or the Mersenne Twister MT19937.  The app will then try to\npredict following numbers from the generator.\n\nThe app expects all numbers to be entered as integers or floating point\nnumbers between zero and one.  Currently, floating point numbers are\nsupported for the Mersenne Twister only.  Three input modes are\nsupported:\n\n1. *Text field* lets you enter the numbers directly on the device.\n2. *File* lets you choose a file with newline separated number strings.\n3. *Socket* opens a server socket on the device.  You can then connect\nwith a custom client by means of a client socket and send newline\nseparated number strings to the server.  After each number the server\nwill send back the next newline separated predictions.  Each block of\npredictions is separated by an additional newline.\n\nTo test the app, enter the following numbers in the *Text field*:\n```\n1412437139\n1552322984\n168467398\n1111755060\n-928874005\n```\nThese numbers were sampled from the Java linear congruential generator\n`Random.nextInt()`.  Thus, the app should detect `LCG: Java` after the\nthird number input, and numbers in the prediction history should appear\nin green instead of red, indicating that those numbers were correctly\npredicted.\n\nThe following Python program can be used to test socket input.  The\nprogram samples numbers from the standard Python pseudo random number\ngenerator and sends them to a network socket:\n```python\nimport random\nimport socket\n\nHOST = \"localhost\"  # Host of Android device\nPORT = 6869  # Default Derandom port\nwith socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:\n    s.connect((HOST, PORT))\n    buffer = s.makefile()  # Buffer for readline\n    for _ in range(0, 700):\n        # Sample bits from generator\n        bits = random.getrandbits(32)\n        # Send number string\n        message = str(bits) + \"\\n\"\n        s.sendall(message.encode())\n        # Read and print predictions\n        for _ in range(0, 9):  # 8 predictions and newline\n            line = buffer.readline()\n            print(line, end=\"\")\n```\nStart the app on the Android device and set the input spinner from\n*Text field* to *Socket*.  Make sure that the device and the Derandom\nsocket port (default 6869) are reachable in your network.  Then set\n`HOST` in the Python program to the address of your Android device and\nrun the program.  For each number that is sent by the Python program,\neight predictions are returned by Derandom and displayed by the Python\nprogram.  After the app has received 624 numbers the Python Mersenne\nTwister should be detected and, in the app, numbers in the prediction\nhistory should appear in green instead of red.  You can also replace\n`random.getrandbits(32)` with `random.random()` and send 1300 numbers\ninstead of 700 numbers to account for unobserved bits.\n\n\nBuilding from source\n--------------------\n\nDefine SDK location with `sdk.dir` in the `local.properties` file or with\nan `ANDROID_HOME` environment variable.  Then type the following command\nto build in release mode:\n```shell\n./gradlew assembleRelease\n```\n\n\nLicense\n-------\n\n```text\nCopyright (C) 2015-2024 Arno Onken\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n     http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasnelt%2Fderandom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasnelt%2Fderandom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasnelt%2Fderandom/lists"}