{"id":19292400,"url":"https://github.com/foolin/mixer","last_synced_at":"2025-04-22T07:31:40.463Z","repository":{"id":57529472,"uuid":"260434176","full_name":"foolin/mixer","owner":"foolin","description":"Mixer is a very simple encrypt and decrypt golang library for short strings such as id or hash.","archived":false,"fork":false,"pushed_at":"2020-05-17T10:40:28.000Z","size":73,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T20:32:30.159Z","etag":null,"topics":["decode","decrypt","encode","encrypt","golang","hash","id","identity","lcg","password","pseudo-random","salt","string","symmetrical-encryption"],"latest_commit_sha":null,"homepage":"","language":"Go","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/foolin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-01T10:36:09.000Z","updated_at":"2024-04-08T06:50:51.000Z","dependencies_parsed_at":"2022-08-26T03:51:29.025Z","dependency_job_id":null,"html_url":"https://github.com/foolin/mixer","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foolin%2Fmixer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foolin%2Fmixer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foolin%2Fmixer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foolin%2Fmixer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foolin","download_url":"https://codeload.github.com/foolin/mixer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250195033,"owners_count":21390230,"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":["decode","decrypt","encode","encrypt","golang","hash","id","identity","lcg","password","pseudo-random","salt","string","symmetrical-encryption"],"created_at":"2024-11-09T22:30:37.005Z","updated_at":"2025-04-22T07:31:40.205Z","avatar_url":"https://github.com/foolin.png","language":"Go","readme":"# mixer\n\n[![go-doc-img]][go-doc] [![travis-img]][travis] [![go-report-card-img]][go-report-card] [![Coverage Status][cov-img]][cov]\n\n\nMixer is a very simple encrypt and decrypt golang library for short strings such as id or hash.\n\n\n## Features\n\n* **Security** - Support for password(salt) encryption.\n* **Symmetrical** Support decrypt from the encrypted string.\n* **Equal length** - The length of the encrypted string is equal to the length of the original string.\n* **Simple** - The encryption algorithm works by replacing and mixing characters.\n* **Custom** Support for custom replacement characters.\n* **LCG algorithm** Use Linear Congruential Generator (LCG) algorithm to generate pseudorandom numbers.\n* **ID Number Padding** Support number padding for ID number(default is padding 16 characters)\n\n## Install\n\n```bash\ngo get -u github.com/foolin/mixer\n```\n\nOr get the specified version:\n```bash\ngo get github.com/foolin/mixer@{version}\n```\nThe {version} release list: \u003chttps://github.com/foolin/mixer/releases\u003e\n\n# Docs\n\nSee [Mixer Godoc](https://pkg.go.dev/github.com/foolin/mixer)\n\n# Usage\n\n- ID(uint64) Example:\n\n```golang\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/foolin/mixer\"\n)\n\nfunc main() {\n\n\t//the source to be encrypted\n\tsources := []uint64{\n\t\t0,\n\t\t123,\n\t\t123456,\n\t\t1234567890,\n\t\t999999999,\n\t\t9223372036854775808,\n\t\t18446744073709551615,\n\t}\n\n\t//password\n\tpassword := \"1q2w3e\"\n\n\t//foreach every source\n\tfor _, source := range sources {\n\n\t\t//Encode source data\n\t\tencodeData := mixer.EncodeID(password, source)\n\n\t\t//Decode source data\n\t\tdecodeData, err := mixer.DecodeID(password, encodeData)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\t//Encode source data with padding 20\n\t\tencodePaddingData := mixer.EncodeIDPadding(password, source, 20)\n\n\t\t//Decode source padding data\n\t\tdecodePaddingData, err := mixer.DecodeID(password, encodeData)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\t//Output result\n\t\tfmt.Printf(\"-------\\nsource: %v\\nencode: %v\\ndecode: %v\\nencodePadding(20): %v\\ndecodePadding(20): %v\\n-------\\n\",\n\t\t\tsource, encodeData, decodeData, encodePaddingData, decodePaddingData)\n\t}\n\n}\n\n\n```\n\nRun output:\n```\n-------\nsource: 0\nencode: 0BAN5S350WAZ3JQW\ndecode: 0\nencodePadding(20): 0BA85SS50WAZ3OQLW3NJ\ndecodePadding(20): 0\n-------\n-------\nsource: 123\nencode: S0QWFABN30J5Z0QH\ndecode: 123\nencodePadding(20): S0Q3FAAN30J5ZLQWHBW0\ndecodePadding(20): 123\n-------\n-------\nsource: 123456\nencode: B0Q8FC4OQ3NASWQH\ndecode: 123456\nencodePadding(20): B0Q0FC5OQ3NASJQ0H48W\ndecodePadding(20): 123456\n-------\n-------\nsource: 1234567890\nencode: K0Q8FC4OQSL33ZQH\ndecode: 1234567890\nencodePadding(20): K0QAFCWOQSL333QBH48Z\ndecodePadding(20): 1234567890\n-------\n-------\nsource: 999999999\nencode: 77JLF0SFNS9JBZNZ\ndecode: 999999999\nencodePadding(20): 77J3F0AFNS9JBNNWZSLZ\ndecodePadding(20): 999999999\n-------\n-------\nsource: 9223372036854775808\nencode: 059Y4Z77Q0052GNN5W0HFQWZFHSHM50\ndecode: 9223372036854775808\nencodePadding(20): 059Y4Z77Q0052GNN5W0HFQWZFHSHM50\ndecodePadding(20): 9223372036854775808\n-------\n-------\nsource: 18446744073709551615\nencode: YL5KS2O7QL89GCQQW48H9QWZFCWZMW7H\ndecode: 18446744073709551615\nencodePadding(20): YL5KS2O7QL89GCQQW48H9QWZFCWZMW7H\ndecodePadding(20): 18446744073709551615\n-------\n\n```\n\n- String Example:\n\n\n```golang\n\npackage main\n\nimport (\n\t\"crypto/md5\"\n\t\"fmt\"\n\t\"github.com/foolin/mixer\"\n)\n\nfunc main() {\n\t//the source to be encrypted\n\tsources := []string{\n\t\t\"abc012345edf\",\n\t\t\"0123456789abcdefghijklmnopqrstuvwxyz\",\n\t\tfmt.Sprintf(\"%x\", md5.Sum([]byte(\"Hello Mixer\"))),\n\t}\n\n\t//password\n\tpassword := \"1q2w3e\"\n\n\t//foreach every source\n\tfor _, source := range sources {\n\t\t//Encode source data\n\t\tencodeData := mixer.EncodeString(password, source)\n\n\t\t//Decode source data\n\t\tdecodeData := mixer.DecodeString(password, encodeData)\n\n\t\t//Output result\n\t\tfmt.Printf(\"-------\\nsource: %v\\nencode: %v\\ndecode: %v\\n-------\\n\",\n\t\t\tsource, encodeData, decodeData)\n\t}\n\n}\n\n\n```\n\nRun output:\n```\n\n-------\nsource: abc012345edf\nencode: hruC87FfRv5N\ndecode: abc012345edf\n-------\n-------\nsource: 0123456789abcdefghijklmnopqrstuvwxyz\nencode: 5B6oSK3Q1wfrvHNqjRp87LhlucJ0Xn2CFaIt\ndecode: 0123456789abcdefghijklmnopqrstuvwxyz\n-------\n-------\nsource: 51f5df9e0e802ed54465638ba31158c2\nencode: 1rppCfufN1hFR8R7RvQNh5fRuF1uC7vR\ndecode: 51f5df9e0e802ed54465638ba31158c2\n-------\n\n```\n\n\n# Todo\n\n###  Other languages Implementations\n\n- [ ] Java Implementation\n- [ ] PHP Implementation\n- [ ] Javascript Implementation\n\n[go-doc]: https://pkg.go.dev/github.com/foolin/mixer\n[go-doc-img]: https://godoc.org/github.com/foolin/mixer?status.svg\n[travis]: https://travis-ci.org/foolin/mixer\n[travis-img]: https://travis-ci.org/foolin/mixer.svg?branch=master\u0026t=mixer\n[go-report-card]: https://goreportcard.com/report/github.com/foolin/mixer\n[go-report-card-img]: https://goreportcard.com/badge/github.com/foolin/mixer\n[cov-img]: https://codecov.io/gh/foolin/mixer/branch/master/graph/badge.svg\n[cov]: https://codecov.io/gh/foolin/mixer","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoolin%2Fmixer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoolin%2Fmixer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoolin%2Fmixer/lists"}