{"id":18657265,"url":"https://github.com/thealoneprogrammer/query-string-hash","last_synced_at":"2025-11-05T21:30:31.286Z","repository":{"id":41456945,"uuid":"355969380","full_name":"thealoneprogrammer/query-string-hash","owner":"thealoneprogrammer","description":"query-string-hash hides the query string params by encrypting them it into a hashed string which can be used as a single query string param.","archived":false,"fork":false,"pushed_at":"2022-07-02T07:20:35.000Z","size":105,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T01:46:57.409Z","etag":null,"topics":["decryption","encryption","hash","npm-package","querystring"],"latest_commit_sha":null,"homepage":"","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/thealoneprogrammer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-08T15:57:33.000Z","updated_at":"2022-07-02T07:17:26.000Z","dependencies_parsed_at":"2022-08-26T12:34:12.223Z","dependency_job_id":null,"html_url":"https://github.com/thealoneprogrammer/query-string-hash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thealoneprogrammer%2Fquery-string-hash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thealoneprogrammer%2Fquery-string-hash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thealoneprogrammer%2Fquery-string-hash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thealoneprogrammer%2Fquery-string-hash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thealoneprogrammer","download_url":"https://codeload.github.com/thealoneprogrammer/query-string-hash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239474725,"owners_count":19644973,"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":["decryption","encryption","hash","npm-package","querystring"],"created_at":"2024-11-07T07:27:22.555Z","updated_at":"2025-11-05T21:30:31.228Z","avatar_url":"https://github.com/thealoneprogrammer.png","language":"JavaScript","readme":"##  **query-string-hash**\n\u003e **Encrypt and Decrypt query string**\n\nquery-string-hash hides the query string params by encrypting them it into two way hash.\n\n## **How it works?**\n- Hides query params from URL by hashing them.\n- Encrypt the query params with a strong key.\n- Decrypt and get JSON by using the same key.\n\n## **Install**\n```sh \n$ npm install query-string-hash \nOR\n$ yarn add query-string-hash\n```\n\nThis module uses [simple-encryptor](https://www.npmjs.com/package/simple-encryptor). to encrypt and decrypt the string and [query-string](https://www.npmjs.com/package/query-string) to parse the string.\n\n\n## **Usage**\n\n##### **At encryption side**\n\n```js\nconst { encryptQueryParams } = require('query-string-hash')\nconst key = \"real secret keys should be long and random\"; //Encryption key (optional) should be atleast 16 characters long.\n\nconst queryParams = 'name=John\u0026\u0026age=22\u0026\u0026number=9876543210'; //query string params which you want to encrypt\nconst hash = encryptQueryParams(queryParams, key) // returns the encryptd hash which can be used as a single query string while routing\nOr\nconst hash = encryptQueryParams(queryParams) // key is optional.\n\n// Output \nhash = 0561267fc5adccb1a3898b2d24af78b1eb69b980b5a1180d60494f9d64afccbd081b27110880da8fadbe10ffa3fa4420uO8Ub4lj652Veq5u4DraQ2YH9j96/VjfFMQfJaYE7W05io6I4WQgV8QbZAA+Wc4R\n```\n\n##### **At decryption side**\n\n```js\nconst { decryptQueryParams } = require('query-string-hash')\nconst key = \"real secret keys should be long and random\";\n\nconst queryParams = decryptQueryParams(hash, key) //returns the decrypted query params which can be used for further processing in JSON format.\nOr\nconst queryParams = decryptQueryParams(hash) //key is optional\n\n// Output \nqueryParams = {\n  age: '22',\n  name: 'John',\n  number: '9876543210'\n}\n```\n\n## **Usage with ES6**\n```js\nimport { encryptQueryParams, decryptQueryParams } from \"query-string-hash\";\n```\n\n## **Options**\n1. **hash**: {\n    type: string,\n    required: true\n}\n2. **key**: {\n    type: string,\n    required: false\n}\n\n## **Example**\nUsage with Vue\nURL ``` https://example.com?name=John\u0026\u0026age=22\u0026\u0026number=9876543210``` can be encrypred as below\n```js\n  import { encryptQueryParams } from 'query-string-hash'\n  export default {\n      // other options\n      methods: {\n          exampleFunc() {\n\t\t\t\tconst key = \"real secret keys should be long and random\";\n            \tconst queryParams = 'name=John\u0026\u0026age=22\u0026\u0026number=9876543210'; \n\t\t\t\tconst hash = encryptQueryParams(queryParams, key)\n                Or\n                const hash = encryptQueryParams(queryParams) // key is optional.\n            \tthis.$router.push(`https://example.com?hash=${hash}`)\n          }\n      }\n  }\n```\nAbove URL becomes ```https://example.com?hash=0561267fc5adccb1a3898b2d24af78b1eb69b980b5a1180d60494f9d64afccbd081b27110880da8fadbe10ffa3fa4420uO8Ub4lj652Veq5u4DraQ2YH9j96/VjfFMQfJaYE7W05io6I4WQgV8QbZAA+Wc4R```\n\nAt decryption side\nExtract query string from ```https://example.com?hash=0561267fc5adccb1a3898b2d24af78b1eb69b980b5a1180d60494f9d64afccbd081b27110880da8fadbe10ffa3fa4420uO8Ub4lj652Veq5u4DraQ2YH9j96/VjfFMQfJaYE7W05io6I4WQgV8QbZAA+Wc4R```\n```js\nimport { decryptQueryParams } from 'query-string-hash'\n  export default {\n      // other options\n      methods: {\n          exampleFunc() {\n\t\t\t\tconst key = \"real secret keys should be long and random\";\n                const queryParams = decryptQueryParams(this.$route.query.hash, key)\n                Or\n                const queryParams = decryptQueryParams(this.$route.query.hash) //key is optional\n                \n                //play with decrypted params ie; queryParams\n          }\n      }\n  }\n```\nGives us ```{\n  age: '22',\n  name: 'John',\n  number: '9876543210'\n}```\n## **Development**\nInstall packages\n```sh\n$ npm install\n```\nBuild\n```sh\n$ npm run build\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthealoneprogrammer%2Fquery-string-hash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthealoneprogrammer%2Fquery-string-hash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthealoneprogrammer%2Fquery-string-hash/lists"}