{"id":20589631,"url":"https://github.com/DO-SAY-GO/floppsy","last_synced_at":"2025-05-09T22:31:27.813Z","repository":{"id":42876563,"uuid":"93734614","full_name":"DO-SAY-GO/floppsy","owner":"DO-SAY-GO","description":":baby_chick: floppsy - SMHasher-passing 200Mb/s hash using floating-point ops","archived":false,"fork":false,"pushed_at":"2023-07-08T14:48:38.000Z","size":761,"stargazers_count":12,"open_issues_count":10,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-05T16:07:29.211Z","etag":null,"topics":["continued-fractions","cryptography","cryptohash","egyptian-fractions","floating-point","hashing","hashing-algorithm","slow","smhasher","tiny"],"latest_commit_sha":null,"homepage":"https://88e9g.csb.app/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DO-SAY-GO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"crislin2046"}},"created_at":"2017-06-08T09:59:41.000Z","updated_at":"2024-02-01T17:44:32.000Z","dependencies_parsed_at":"2024-10-24T02:07:58.979Z","dependency_job_id":"783ee505-1601-4176-8ee5-b3b1b8012974","html_url":"https://github.com/DO-SAY-GO/floppsy","commit_stats":null,"previous_names":["crislin2046/floppsy","dosaygo-coder-0/tifuhash","do-say-go/floppsy"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DO-SAY-GO%2Ffloppsy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DO-SAY-GO%2Ffloppsy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DO-SAY-GO%2Ffloppsy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DO-SAY-GO%2Ffloppsy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DO-SAY-GO","download_url":"https://codeload.github.com/DO-SAY-GO/floppsy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112074,"owners_count":21856070,"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":["continued-fractions","cryptography","cryptohash","egyptian-fractions","floating-point","hashing","hashing-algorithm","slow","smhasher","tiny"],"created_at":"2024-11-16T07:30:09.204Z","updated_at":"2025-05-09T22:31:27.371Z","avatar_url":"https://github.com/DO-SAY-GO.png","language":"JavaScript","readme":"# :baby_chick: [floppsy](https://github.com/dosyago/floppsy) \n\n#### **[200MB/s SMHasher](https://github.com/rurban/smhasher/blob/master/doc/floppsyhash.txt)** [![version](https://img.shields.io/npm/v/floppsy.svg?label=\u0026color=0080FF)](https://github.com/dosyago/floppsy/releases/latest) ![npm downloads](https://img.shields.io/npm/dt/floppsy)\n\nA tiny, simple and SMHasher-passing slow (200Mb/s) hash designed for floating point hardware. It's also non-deterministic (different values depend on architecture, due to quirks and differences in floating point implementations). \n\n[Link to the SUPERCOP ECRYPT benchmark for floppsy](https://bench.cr.yp.to/impl-hash/floppsy.html)\n\n## demo\n\n[play with a demo online here](https://88e9g.csb.app/)\n\n## construction\n\nconstructed using floating point multiplication, division and addition.\n\nbased on continued and egyptian fractions.\n\n*no bit operations used in the making of this hash.*\n\n## accolades\n\npasses [smhasher](https://github.com/rurban/smhasher)\n\n[see the results for all tests](https://github.com/crislin2046/floppsy/blob/master/smhasher.results.txt)\n\nalso see [an independent confirmation of these results](https://github.com/rurban/smhasher/blob/master/doc/floppsyhash.txt)\n\n\n## c source\n\n```c++\nFORCE_INLINE void q ( double * state, double key_val, \n         double numerator, double denominator )\n{\n  state[0] += numerator / denominator;\n  state[0] = 1.0 / state[0];\n\n  state[1] += key_val + M_PI;\n  state[1] = numerator / state[1];\n}\n\n//---------\n// round function : process the message \n\nFORCE_INLINE void round ( const uint8_t * msg, long len, \n            double * state ) \n{\n  double numerator = 1.0;\n\n  // Loop\n  for( long i = 0; i \u003c len; i++ ) {\n    double val = (double)msg[i];\n    double denominator = (M_E * val + i + 1) / state[1];\n\n    q( state, val, numerator, denominator );\n\n    numerator = denominator + 1;\n  }\n}\n\n//---------\n// setup function : setup the state\n\nFORCE_INLINE void setup ( double * state, double init = 0 ) \n{\n  state[0] += init != 0 ? pow(init + 1.0/init, 1.0/3) : 3.0;\n  state[1] += init != 0 ? pow(init + 1.0/init, 1.0/7) : 1.0/7;\n}\n\n//---------\n// floppsyhash\n// with 64 bit continued egyptian fractions\n\nvoid floppsyhash_64 ( const void * key, int len,\n                   uint32_t seed, void * out )\n{\n  const uint8_t * data = (const uint8_t *)key;\n  uint8_t buf [16];\n  double * state = (double*)buf;\n  uint32_t * state32 = (uint32_t*)buf;\n  double seed32 = (double)seed;\n\n  uint8_t * seedbuf;\n  seedbuf = (uint8_t *)\u0026seed;\n\n  setup( state, seed32 );\n  round( seedbuf, 4, state );\n  round( data, len, state );\n\n  uint8_t output [8];\n  uint32_t * h = (uint32_t*)output;\n  \n  h[0] = state32[0] + state32[3];\n  h[1] = state32[1] + state32[2];\n\n  ((uint32_t*)out)[0] = h[0];\n  ((uint32_t*)out)[1] = h[1];\n} \n```\n## disclaimer\n\nno claims are made regarding the security of this system. \n\n## get\n\n```console\nnpm i --save floppsy\n```\n\n## use-cases\n\n- A slow hash for password hashing. \n- Hashing arrays of numbers (vectors, floating point).\n- As a basis for a cryptographic primitive (such as a PRNG, or symmetric cipher).\n\n## include\n\nAs a Node ES module:\n\n```javascript\nimport floppsy from 'floppsy';\n```\n\nAs old style modules:\n\n```javascript\nconst floppsy = require('floppsy').default;\n```\n\nUsing [Snowpack](https://github.com/pikapkg/snowpack) in a web app:\n\n```javascript\nimport floppsy from './web_modules/floppsy.js';\n```\n\n## api\n\nCan produce digests of 32, 64 or 128 bits.\n\n```console\n\u003e f.hash('')\n'7f5f8491f0b745bf'\n\u003e f.hash('', {bits:32})\n'7016ca50'\n\u003e f.hash('', {bits:128})\n'3f7f508e3fe034033ff0e269b0c66356'\n```\n\n*Can also change output format:*\n\n```javascript\n  x.hash('',{out_format:'hex'}); // default\n  x.hash('',{out_format:'binary'}); // binary string\n  x.hash('',{out_format:'bytes'}); // Uint8Array\n  x.hash('',{out_format:'uint32s'}); // Uint32Array\n```\n\n---------------\n\n[play with a demo online here](https://codesandbox.io/s/blue-cache-88e9g?fontsize=14\u0026hidenavigation=1\u0026theme=dark)\n","funding_links":["https://github.com/sponsors/crislin2046"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDO-SAY-GO%2Ffloppsy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDO-SAY-GO%2Ffloppsy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDO-SAY-GO%2Ffloppsy/lists"}