{"id":29968140,"url":"https://github.com/durosoft/node-utils","last_synced_at":"2026-04-18T19:33:23.552Z","repository":{"id":85503048,"uuid":"109933093","full_name":"DuroSoft/node-utils","owner":"DuroSoft","description":"Publicly accessible Node.js utility functions used in various DuroSoft projects and in Google Cloud Functions","archived":false,"fork":false,"pushed_at":"2017-11-08T08:11:58.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-04T03:39:15.772Z","etag":null,"topics":["encryption","io","javascript","nodejs","string-manipulation","utility-library"],"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/DuroSoft.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-11-08T05:47:03.000Z","updated_at":"2017-11-11T18:55:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"30b22921-42b4-4455-a65e-57538cc858d9","html_url":"https://github.com/DuroSoft/node-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DuroSoft/node-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DuroSoft%2Fnode-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DuroSoft%2Fnode-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DuroSoft%2Fnode-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DuroSoft%2Fnode-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DuroSoft","download_url":"https://codeload.github.com/DuroSoft/node-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DuroSoft%2Fnode-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31982742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["encryption","io","javascript","nodejs","string-manipulation","utility-library"],"created_at":"2025-08-04T03:07:35.347Z","updated_at":"2026-04-18T19:33:23.539Z","avatar_url":"https://github.com/DuroSoft.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-utils\nThis Node.js package contains a number of JavaScript utility functions used\nthroughout various DuroSoft open and closed source projects. These functions\nare licensed under the MIT License and can be freely used however you see\nfit so long as attribution is retained.\n\n## Usage\n\n`$ npm install --save durosoft/node-utils`\n\n```javascript\nconst utils = require('utils');\nconsole.log(utils.randomAlphaNumeric(26));\n```\n\n\n## Random Number Generation\n\n### utils.randomAlphaNumeric(size)\nReturns a secure (thanks to `secure-random`) random alpha-numeric string of the\nspecified length.\n\n```javascript\n\u003e utils.randomAlphaNumeric(32);\n'BfRbHDi2kBSGnUat3OWk6i6BhF7oCnDl'\n```\n\n### utils.randomInt(a, b)\nReturns a secure random integer between *a* (inclusive) and *b* (exclusive). *a* and\n*b* default to 0 and the highest possible JavaScript integer, respectively, so calling\n`randomInt()` with no arguments results in a secure random positive integer over the\nrange of all possible positive JavaScript integers (excluding the highest\npossible integer, since *b* is exclusive).\n\n```javascript\n\u003e utils.randomInt();\n190759654058180\n\u003e utils.randomInt(-5, 5);\n-2\n\u003e utils.randomInt(0, 100);\n39\n```\n\n\n## Cryptography\n\n### utils.setCryptoAlgorithm(algorithm)\nSets the current encryption/decryption algorithm used by the system. Defaults to\n`'aes-256-gcm'`, which corresponds with 256-bit AES encryption in GCM mode.\n\n```javascript\n\u003e utils.setCryptoAlgorithm('aes-128-gcm');\n```\n\n### utils.setCryptoKey(buffer)\nSets the current encryption key used by the system, specified by a Buffer of the proper\nlength (by default, you would want a length of 32). If you do not call this method,\nthe default encryption key is initialized to a securely-random buffer of length 32.\n\n```javascript\n\u003e utils.setCryptoKey(secureRandom(32, {type: 'Buffer'}));\n```\n\n### utils.saveCryptoKey(path)\nSaves the current encryption key to the specified path. The key is encoded as\na raw binary file.\n\n```javascript\n\u003e utils.saveCryptoKey('key.aes');\n```\n\n### utils.loadCryptoKey(path)\nLoads an encryption key that was saved using `utils.saveCryptoKey(path)` and sets it\nas the current encryption key.\n\n```javascript\n\u003e utils.loadCryptoKey('key.aes');\n```\n\n### utils.getCryptoKey()\nRetrieves the current encryption key as a raw Buffer.\n\n```\n\u003e utils.getCryptoKey();\n\u003cBuffer 7b 1c c5 b5 4c e7 c5 6d 61 28 52 4b b9 1e 42 b5 0b 50 7c f3 4c a2...\u003e\n```\n\n### utils.generateCryptoKey()\nSecurely generates a securely random encryption key and sets it as current.\n\n```javascript\n\u003e utils.generateCryptoKey();\n```\n\n### utils.encryptText(text)\nEncrypts and returns the specified text using the current crypto algorithm and key. By\ndefault, a proper salt, IV, and auth tag are generated and encoded.\n\n```javascript\n\u003e utils.encryptText('hey');\n'SQujuqBHpKGX87LMKvKtbw309xIe0OtRMSx9/eqpMn7BYY691PTqJcsooSt0IoqKNoUZM7...'\n```\n\n### utils.decryptText(text)\nDecrypts and returns the specified cipher text using the current crypto algorithm and\nkey. Assumes that the text was encrypted using `utils.encryptText()` and the current\ncrypto key and algorithm.\n\n```javascript\n\u003e utils.decryptText('SQujuqBHpKGX87LMKvKtbw309xIe0OtRMSx9/eqpMn7BYY691P...');\n'hey'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdurosoft%2Fnode-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdurosoft%2Fnode-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdurosoft%2Fnode-utils/lists"}