{"id":19778328,"url":"https://github.com/npkgz/crypto-magic","last_synced_at":"2025-10-24T13:09:31.133Z","repository":{"id":66170244,"uuid":"335902761","full_name":"npkgz/crypto-magic","owner":"npkgz","description":"crypto related functions","archived":false,"fork":false,"pushed_at":"2021-02-05T20:10:35.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-23T06:58:20.478Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/crypto-magic","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/npkgz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","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}},"created_at":"2021-02-04T09:27:30.000Z","updated_at":"2021-02-05T20:12:17.000Z","dependencies_parsed_at":"2023-05-23T19:45:33.353Z","dependency_job_id":null,"html_url":"https://github.com/npkgz/crypto-magic","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"54ec6fd47b9e32384d795b180f1c35459898b815"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fcrypto-magic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fcrypto-magic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fcrypto-magic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fcrypto-magic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npkgz","download_url":"https://codeload.github.com/npkgz/crypto-magic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241108392,"owners_count":19910980,"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":[],"created_at":"2024-11-12T05:28:55.627Z","updated_at":"2025-10-24T13:09:31.080Z","avatar_url":"https://github.com/npkgz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"crypto-magic\n==============\n\nA set of utility functions/wrapper to simplify the development workflow\n\n```bash\n$ yarn add crypto-magic\n```\n\nFeatures\n--------\n\n* Hash Function Wrapper (MD5, SHA1, SHA244, SHA256, SHA384, SHA512, WHIRLPOOL)\n* Create Object/Array Hashes based on its JSON representation\n* UUIDv4 generator usinc async crypto api `randomBytes`\n* base64 urlsafe encoder/decoder\n\nHash Function Wrapper\n---------------------\n\nProvides easy access to the [Node.js Crypto Hash](https://nodejs.org/api/crypto.html#crypto_class_hash) functions. Examples are available in [examples/hash.js](examples/hashes.js)\n\n```js\nconst {hash} = require('crypto-magic');\n\nconsole.log(hash.sha256('Hello World'));\n```\n\n##### Initialization #####\n\nThe argument `encoding` is optional and defines the output encoding of the digest.\n\n * **hex** (default) - hexadecimal string output\n * **base64** - base64 string output\n * **base64urlsafe** - url-safe base64 string output (**/+=** are replaced by **_-**)\n * **binary** - binary output as [Buffer](https://nodejs.org/api/buffer.html)\n\n##### Hash Algorithms #####\n\nThe following wrappers are included:\n\n * `md5(input:mixed, [encoding:string])`\n * `sha1(input:mixed, [encoding:string])`\n * `sha2(input:mixed, [encoding:string])`\n * `sha224(input:mixed, [encoding:string])`\n * `sha256(input:mixed, [encoding:string])`\n * `sha384(input:mixed, [encoding:string])`\n * `sha512(input:mixed, [encoding:string])`\n * `whirlpool(input:mixed, [encoding:string])` \n \n### General Usage ###\n\n```js\nconst {hash} = require('crypto-magic');\n\n// some input\nconst input = 'Hello World';\n\n// display some hashes\nconsole.log('Default HEX Output');\nconsole.log(' |- MD5      ', hash.md5(input));\nconsole.log(' |- SHA1     ', hash.sha1(input));\nconsole.log(' |- SHA256   ', hash.sha256(input));\nconsole.log(' |- SHA384   ', hash.sha384(input));\nconsole.log(' |- SHA512   ', hash.sha512(input));\nconsole.log(' |- WHIRLPOOL', hash.whirlpool(input));\n\n// override the default output type\nconsole.log('Override the default output settings');\nconsole.log(' |- HEX      ', hash.sha1(input, 'hex'));\nconsole.log(' |- BIN      ', hash.sha1(input, 'binary'));\nconsole.log(' |- BASE64   ', hash.sha1(input, 'base64'));\nconsole.log('');\n```\n\n### Objects ###\n\nObjects/Arrays are automatically serialized as JSON String. The JSON object is then passed into the hash function.\n\n```js\nconst {hash} = require('crypto-magic');\n\n// demo object\nconst objectInput = {\n    x: 1,\n    b: 2,\n    c: [5,6,7],\n    d: {\n        y: 'Hello',\n        z: 'World'\n    }\n};\n\nconsole.log('Object Input');\nconsole.log(' |- SHA256   ', hash.sha256(objectInput));\n```\n\nRandom Hash Generator\n---------------------\n\nCreate random hashes easily. Just calls the `crypto-magic.hash` functions with a random content generated by `crypto-magic.random(514)` - helpful for random URLs or filenames (e.g. cache hashes).\n\n```js\n// url-safe base64\nconst {randomHash} = require('crypto-magic');\n\n// all hash function of crypto-magic.hash are supported\nconsole.log(await randomHash.sha256('base64urlsafe'));\n\n// output like b7qhqd-WnKAH_GmBpSpvQrdkfUdLxL0m__XGcLTRsbI\n```\n\n## License ##\ncrypto-magic is OpenSource and licensed under the Terms of [The MIT License (X11)](http://opensource.org/licenses/MIT) - your're welcome to contribute\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Fcrypto-magic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpkgz%2Fcrypto-magic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Fcrypto-magic/lists"}