{"id":22280978,"url":"https://github.com/togatech/tenvoy","last_synced_at":"2025-07-28T19:33:04.513Z","repository":{"id":39764158,"uuid":"337790111","full_name":"TogaTech/tEnvoy","owner":"TogaTech","description":"PGP, NaCl, and PBKDF2 in node.js and the browser (hashing, random, encryption, decryption, signatures, conversions), used by TogaTech.org","archived":false,"fork":false,"pushed_at":"2022-12-12T03:33:38.000Z","size":58667,"stargazers_count":3,"open_issues_count":17,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-09T20:34:03.406Z","etag":null,"topics":["cryptographic-random-generator","cryptography","decryption","encryption","encryption-decryption","hash","hash-functions","hashing","javascript","md5","md5-hash","nacl","openpgp","pbkdf2","pgp","sha256","sha256-hash","signature-verification","signatures","tweetnacl"],"latest_commit_sha":null,"homepage":"https://tenvoy.js.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TogaTech.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}},"created_at":"2021-02-10T16:52:56.000Z","updated_at":"2021-12-29T21:54:39.000Z","dependencies_parsed_at":"2022-09-07T09:10:30.404Z","dependency_job_id":null,"html_url":"https://github.com/TogaTech/tEnvoy","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TogaTech%2FtEnvoy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TogaTech%2FtEnvoy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TogaTech%2FtEnvoy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TogaTech%2FtEnvoy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TogaTech","download_url":"https://codeload.github.com/TogaTech/tEnvoy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227951784,"owners_count":17846345,"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":["cryptographic-random-generator","cryptography","decryption","encryption","encryption-decryption","hash","hash-functions","hashing","javascript","md5","md5-hash","nacl","openpgp","pbkdf2","pgp","sha256","sha256-hash","signature-verification","signatures","tweetnacl"],"created_at":"2024-12-03T16:11:19.692Z","updated_at":"2025-07-28T19:33:04.505Z","avatar_url":"https://github.com/TogaTech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://togatech.org/\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n\t\t\u003cimg src=\"https://togatech.org/favicon.png\" width=\"100\" alt=\"TogaTech Logo\"\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003etEnvoy\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://github.com/TogaTech/tEnvoy/actions\"\u003e\u003cimg src=\"https://img.shields.io/github/workflow/status/TogaTech/tEnvoy/Node.js%20CI\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://www.npmjs.com/package/tenvoy\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/tenvoy.svg?sanitize=true\" alt=\"Version\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://www.npmjs.com/package/tenvoy\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/tenvoy.svg?sanitize=true\" alt=\"License\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://www.npmjs.com/package/tenvoy\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/tenvoy.svg?sanitize=true\" alt=\"Monthly Downloads\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://www.npmjs.com/package/tenvoy\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/tenvoy.svg?sanitize=true\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nPGP, NaCl, and PBKDF2 in node.js and the browser (hashing, random, encryption, decryption, signatures, conversions), used by [TogaTech.org](https://togatech.org/)\n\n# Table of Contents\n- [Imports](#imports)\n\t- [Browser Import](#browser-import)\n\t- [Node.js NPM Import](#nodejs-npm-import)\n\t- [Node.js File Import](#nodejs-file-import)\n- [Minify](#minify)\n- [Dependencies](#dependencies)\n- [Contributing](#contributing)\n- [Quickstart](#quickstart)\n- [Documentation](#documentation)\n\t- [General](#general)\n\t- [Core](#core)\n\t- [Utilities](#utilities)\n\t- [Random](#random)\n\t- [Hashing](#hashing)\n\t- [Key Factory](#key-factory)\n\t- [PGP Keys](#pgp-keys)\n\t- [NaCl Keys](#nacl-keys)\n\t- [NaCl Signing Keys](#nacl-signing-keys)\n- [Cryptography Notice](#cryptography-notice)\n\n# Imports\n\n## Browser Import\nFor the browser, only `./tenvoy.js` or `./tenvoy.min.js` is required and has all dependencies bundled inside the single file. We recommend including `./tenvoy.min.js.map` in the same directory as `./tenvoy.min.js`, which allows a browser to reconstruct the original unminified file in the debugger.\n\n```html\n\u003cscript type=\"text/javascript\" src=\"./tenvoy.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n\tconst envoy = new tEnvoy();\n\u003c/script\u003e\n```\n\n## Node.js NPM Import\ntEnvoy is available through the NPM registry. To install tEnvoy, use the following command in the terminal:\n```bash\nnpm install tenvoy\n```\nTo install tEnvoy into an NPM project, use this command instead:\n```bash\nnpm install tenvoy --save\n```\nMake sure to run the test cases to ensure that tEnvoy works properly:\n```bash\nnpm test\n```\nTo include tEnvoy in your code:\n```javascript\nconst { tEnvoy, tEnvoyPGPKey, tEnvoyNaClKey, tEnvoyNaClSigningKey } = require(\"tenvoy\");\nconst envoy = new tEnvoy();\n```\n\n## Node.js File Import\nFor node.js file import, the filetree must be kept as-is without modifications. The entire repository must be cloned and placed within a directory, and `./node/tenvoy.js` or `./node/tenvoy.min.js` must be used to import the program.\n\nFirst, ensure that all dependencies have been installed:\n```bash\nnpm install\n```\nMake sure to run the test cases to ensure that tEnvoy works properly:\n```bash\nnpm test\n```\nTo include tEnvoy in your code:\n```javascript\nconst { tEnvoy, tEnvoyPGPKey, tEnvoyNaClKey, tEnvoyNaClSigningKey } = require(\"./node/tenvoy.min.js\");\nconst envoy = new tEnvoy();\n```\n\n# Minify\nIf you would like to minify the code yourself instead of using the provided `tenvoy.min.js` (and optional `tenvoy.min.js.map`), you can use [UglifyJS 3](https://github.com/mishoo/UglifyJS) to minifiy the code yourself.\n\nTo install UglifyJS 3 as a command line app through NPM, run `npm install uglify-js -g`.\n\nAfter UglifyJS 3 has been installed, you can run the following commands in your terminal:\n```bash\nuglifyjs ./tenvoy.js -o ./tenvoy.min.js -c -m --source-map \"filename='./tenvoy.min.js.map',url='tenvoy.min.js.map'\"\nuglifyjs ./node/tenvoy.js -o ./node/tenvoy.min.js -c -m --source-map \"filename='./node/tenvoy.min.js.map',url='tenvoy.min.js.map'\"\n```\n\n# Dependencies\n\n# Contributing\n\n# Quickstart\n\n# Documentation\n\n## General\n\n### constructor\nCreates a new instance of tEnvoy\n```javascript\nconst envoy = new tEnvoy(openpgp, nacl, sha256); // tEnvoy {...}\n```\nFor browsers only, a static `window` property contains an instance of tEnvoy by default. This instance is less secure than creating your own scoped instance (due to prototype pollution vulnerabilities) but can be helpful for debugging purposes in the browser console:\n```javascript\nconst envoy = window.TogaTech.tEnvoy; // tEnvoy {...}\n```\n**Parameters:**\n- openpgp (optional, default: `openpgp`): Object (`openpgp`) - a valid instance of [OpenPGP.js](https://github.com/openpgpjs/openpgpjs), `openpgp` is added by default in `tenvoy.js`, but this parameter can be used to provide a modified version of `openpgp` or a polyfill\n- nacl (optional, default: `nacl`): Object (`nacl`) - a valid instance of [TweetNaCl.js](https://github.com/dchest/tweetnacl-js), `nacl` is added by default in `tenvoy.js`, but this parameter can be used to provide a modified version of `nacl` or a polyfill\n- sha256 (optional, default: `sha256`): Object (`sha256`) - a valid instance of [fast-sha256-js](https://github.com/dchest/fast-sha256-js), `sha256` is added by default in `tenvoy.js`, but this parameter can be used to provide a modified version of `sha256` or a polyfill\n\n**Returns:** tEnvoy (`tEnvoy {...}`) - the instance of tEnvoy\n\n### wordsList\nGets or sets the [BIP39 English wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt) as an array of 2048 words, used to generate random words or back up/restore NaCl-based keys\n```javascript\nlet wordsList = envoy.wordsList;  // (2048) ['abandon', 'ability', 'able', 'about', ...]\nenvoy.wordsList = ['abandon', 'ability', 'able', 'about', ...];\n```\n**Type:** Array (`(2048) ['abandon', 'ability', 'able', 'about', ...]`)\n\n**Warning: It is not recommended to modify envoy.wordsList.**\n\n### version\nGets the version (read-only) of tEnvoy\n```javascript\nlet version = envoy.version; // \"v7.0.8\"\n```\n**Type:** string (`\"v7.0.8\"`)\n\n## Core\n\n### core.openpgp\nGets the instance of `openpgp` (read-only) for tEnvoy (can be set in the constructor)\n```javascript\nlet openpgp = envoy.core.openpgp; // {...}\n```\n**Type:** Object (`{...}`)\n\n### core.nacl\nGets the instance of `nacl` (read-only) for tEnvoy (can be set in the constructor)\n```javascript\nlet nacl = envoy.core.nacl; // {...}\n```\n**Type:** Object (`{...}`)\n\n### core.sha256\nGets the instance of `sha256` (read-only) for tEnvoy (can be set in the constructor)\n```javascript\nlet sha256 = envoy.core.sha256; // {...}\n```\n**Type:** Object (`{...}`)\n\n## Utilities\n\n### util.utf8encode\nEncodes a string into a UTF-8 bytes array\n```javascript\nlet bytes = envoy.util.utf8encode(\"test\"); // Uint8Array(4) [116, 101, 115, 116]\n```\n**Parameters:**\n- string (required): string (`\"test\"`) - the string to encode\n\n**Returns:** Uint8Array (`Uint8Array(4) [116, 101, 115, 116]`) - the UTF-8 encoded bytes\n\n### util.utf8decode\nDecodes a UTF-8 bytes array into a string\n```javascript\nlet string = envoy.util.utf8decode(new Uint8Array([116, 101, 115, 116])); // \"test\"\n```\n**Parameters:**\n- bytes (required): Uint8Array or Array (`Uint8Array(4) [116, 101, 115, 116]`) - the bytes to decode\n\n**Returns:** string (`\"test\"`) - the UTF-8 decoded string\n\n### util.stringToBytes\nEncodes a string into a bytes array\n```javascript\nlet bytes = envoy.util.stringToBytes(\"test\"); // Uint8Array(4) [116, 101, 115, 116]\n```\n**Parameters:**\n- string (required): string (`\"test\"`) - the string to encode\n\n**Returns:** Uint8Array (`Uint8Array(4) [116, 101, 115, 116]`) - the encoded bytes\n\n**Warning: While this method is similar to [util.utf8encode](#util-utf8encode), it does not handle UTF-8 encoding for characters outside of the 8 bit range, causing unexpected outputs for UTF-8 characters.**\n\n### util.bytesToString\nDecodes a bytes array into a string\n```javascript\nlet string = envoy.util.utf8decode(new Uint8Array([116, 101, 115, 116])); // \"test\"\n```\n**Parameters:**\n- bytes (required): Uint8Array or Array (`Uint8Array(4) [116, 101, 115, 116]`) - the bytes to decode\n\n**Returns:** string (`\"test\"`) - the decoded string\n\n**Warning: While this method is similar to [util.utf8decode](#util-utf8decode), it does not handle UTF-8 decoding for characters outside of the 8 bit range, causing unexpected outputs for UTF-8 characters.**\n\n### util.stringToHex\nEncodes a string into hexadecimal\n```javascript\nlet hex = envoy.util.stringToHex(\"testing\"); // \"74657374696e67\"\n```\n**Parameters:**\n- string (required): string (`\"testing\"`) - the string to encode \n\n**Returns:** string (`\"74657374696e67\"`) - the encoded hexadecimal\n\n### util.hexToString\nDecodes hexadecimal into a string\n```javascript\nlet hex = envoy.util.hexToString(\"74657374696e67\"); // \"testing\"\n```\n**Parameters:**\n- hex (required): string (`\"74657374696e67\"`) - the hexadecimal to decode\n\n**Returns:** string (`\"testing\"`) - the decoded string\n\n### util.bytesToHex\nEncodes a bytes array into hexadecimal\n```javascript\nlet hex = envoy.util.bytesToHex(new Uint8Array([116, 101, 115, 116, 105, 110, 103])); // \"74657374696e67\"\n```\n**Parameters:**\n- bytes (required): Uint8Array or Array (`new Uint8Array([116, 101, 115, 116, 105, 110, 103])`) - the bytes to encode \n\n**Returns:** string (`\"74657374696e67\"`) - the encoded hexadecimal\n\n### util.hexToBytes\nDecodes hexadecimal into a bytes array\n```javascript\nlet hex = envoy.util.hexToBytes(\"74657374696e67\"); // Uint8Array(7) [116, 101, 115, 116, 105, 110, 103]\n```\n**Parameters:**\n- hex (required): string (`\"74657374696e67\"`) - the hexadecimal to decode\n\n**Returns:** Uint8Array (`Uint8Array(7) [116, 101, 115, 116, 105, 110, 103]`) - the decoded bytes\n\n### util.arrayDeepCopy\nCopies an array and all subarrays to a new array\n```javascript\nlet copy = envoy.util.arrayDeepCopy([1, [2, 3], new Uint8Array([4, 5]), 6]); // [1, [2, 3], Uint8Array(2) [4, 5], 6]\n```\n**Parameters:**\n- hex (required): string (`\"74657374696e67\"`) - the hexadecimal to decode\n\n**Returns:** Uint8Array (`Uint8Array(7) [116, 101, 115, 116, 105, 110, 103]`) - the decoded bytes\n\n### util.compareConstant\nCompares two arguments for index-based equality in almost constant time\n```javascript\nlet equals1 = envoy.util.compareConstant([1, 2], [1, 2]); // true\nlet equals2 = envoy.util.compareConstant([1, 2], [3, 2]); // false\nlet equals3 = envoy.util.compareConstant(new Uint8Array([1, 2]), [1, 2]); // true\nlet equals4 = envoy.util.compareConstant(new Uint16Array([1, 2]), new Uint8Array([1, 2])); // true\nlet equals5 = envoy.util.compareConstant(\"test\", \"test\"); // true\nlet equals6 = envoy.util.compareConstant(\"test\", [\"t\", \"e\", \"s\", \"t\"]); // true\nlet equals7 = envoy.util.compareConstant(\"test\", \"testing\"); // false\n```\n**Parameters:**\n- inputted (required): string or Array or Uint8Array or any index-based object (`[1, 2]`) - the user-inputted argument for comparison\n- original (required): string or Array or Uint8Array or any index-based object (`[1, 2]`) - the stored argument to check the user-inputted argument against\n\n**Returns:** boolean (`true`) - whether the index-based objects are equal (`==`) at every index and have the same length\n\n### util.mixedToUint8Array\nConverts any type to a Uint8Array\n```javascript\nlet uint8array1 = envoy.util.mixedToUint8Array(null); // null\nlet uint8array2 = envoy.util.mixedToUint8Array(new Uint8Array([1, 2])); // Uint8Array(2) [1, 2]\nlet uint8array3 = envoy.util.mixedToUint8Array({0: 1, 1: 2}); // Uint8Array(2) [1, 2]\nlet uint8array4 = envoy.util.mixedToUint8Array([1, 2]); // Uint8Array(2) [1, 2]\nlet uint8array5 = envoy.util.mixedToUint8Array(1); // Uint8Array(1) [1]\nlet uint8array6 = envoy.util.mixedToUint8Array(256); // Uint8Array(2) [1, 0]\nlet uint8array7 = envoy.util.mixedToUint8Array(0); // Uint8Array(1) [0]\nlet uint8array8 = envoy.util.mixedToUint8Array(-1); // Uint8Array(1) [1]\nlet uint8array9 = envoy.util.mixedToUint8Array(-256); // Uint8Array(2) [1, 0]\nlet uint8array10 = envoy.util.mixedToUint8Array(NaN); // Uint8Array(1) [0]\nlet uint8array11 = envoy.util.mixedToUint8Array(1.1); // Uint8Array(3) [49, 46, 49]\nlet uint8array12 = envoy.util.mixedToUint8Array(Infinity); // Uint8Array(1) [255]\nlet uint8array13 = envoy.util.mixedToUint8Array([256, 257]); // Uint8Array(9) [91, 50, 53, 54, 44, 50, 53, 55, 93]\nlet uint8array14 = envoy.util.mixedToUint8Array([\"t\", \"e\", \"s\", \"t\"]); // Uint8Array(17) [91, 34, 116, 34, 44, 34, 101, 34, 44, 34, 115, 34, 44, 34, 116, 34, 93]\nlet uint8array15 = envoy.util.mixedToUint8Array({\"t\": \"e\", \"s\": \"t\"}); // Uint8Array(17) [123, 34, 116, 34, 58, 34, 101, 34, 44, 34, 115, 34, 58, 34, 116, 34, 125]\nlet uint8array16 = envoy.util.mixedToUint8Array(true); // Uint8Array(1) [1]\nlet uint8array17 = envoy.util.mixedToUint8Array(false); // Uint8Array(1) [0]\nlet uint8array18 = envoy.util.mixedToUint8Array(function test() {return \"test\"}); // Uint8Array(31) [102, 117, 110, 99, 116, 105, 111, 110, 32, 116, 101, 115, 116, 40, 41, 32, 123, 114, 101, 116, 117, 114, 110, 32, 34, 116, 101, 115, 116, 34, 125]\nlet uint8array19 = envoy.util.mixedToUint8Array(\"test\"); // Uint8Array(4) [116, 101, 115, 116]\nlet uint8array20 = envoy.util.mixedToUint8Array(\"test\", true); // Uint8Array(5) [254, 116, 101, 115, 116]\nlet uint8array21 = envoy.util.mixedToUint8Array(\"test\", true, 10); // Uint8Array(10) [255, 255, 255, 255, 255, 254, 116, 101, 115, 116]\n```\n**Parameters:**\n- mixed (required): any (`[1, 2]`) - the mixed object to convert to a Uint8Array\n- includeType (optional, default: `false`): boolean (`false`) - whether to include the type of the original mixed object in the Uint8Array\n- length (optional, default: length of return array): number (`2`) - the length of the return array, used to add padding (includeType must be true to use the length argument)\n\n**Mixed Types:**\n- null (`null`) =\u003e null (`null`)\n- undefined (`undefined`) =\u003e undefined (`undefined`)\n- Uint8Array (`new Uint8Array([1, 2])`) =\u003e Uint8Array (`Uint8Array(2) [1, 2]`)\n- Uint8Array-like object (`{0: 1, 1: 2}`) =\u003e mapped keys to indices (`Uint8Array(2) [1, 2]`)\n- Uint8Array-like Array (`[1, 2]`) =\u003e mapped one-to-one Uint8Array (`Uint8Array(2) [1, 2]`)\n- Integer number (`256`) =\u003e base-256 representation of absolute value of number (`Uint8Array(2) [1, 0]`)\n- NaN (`NaN`) =\u003e 0 `Uint8Array(1) [0]`\n- Decimal number (`1.1`) =\u003e UTF-8 encoded string representation of number (`Uint8Array(3) [49, 46, 49]`)\n- Infinity (`Infinity`) =\u003e 255 (`Uint8Array(1) [255]`)\n- Array (`[256, 257]`) =\u003e UTF-8 encoded JSON stringified Array (`Uint8Array(9) [91, 50, 53, 54, 44, 50, 53, 55, 93]`)\n- JSON object or object with toJSON method (`{\"t\": \"e\", \"s\": \"t\"}`) =\u003e UTF-8 encoded JSON stringified Object (`Uint8Array(17) [123, 34, 116, 34, 58, 34, 101, 34, 44, 34, 115, 34, 58, 34, 116, 34, 125]`)\n- true (`true`) =\u003e 1 (`Uint8Array(1) [1]`)\n- false (`false`) =\u003e 0 (`Uint8Array(1) [0]`)\n- function (`function test() {return \"test\"}`) =\u003e UTF-8 encoded string representation of function (`Uint8Array(31) [102, 117, 110, 99, 116, 105, 111, 110, 32, 116, 101, 115, 116, 40, 41, 32, 123, 114, 101, 116, 117, 114, 110, 32, 34, 116, 101, 115, 116, 34, 125]`)\n- string or other (`\"test\"`) =\u003e UTF-8 encoded string or return value of `toString()` (`Uint8Array(4) [116, 101, 115, 116]`)\n\n**Included Types:**\n- Uint8Array: first non-padding byte is `0`\n- Uint8Array-like object: first non-padding byte is `0` (a Uint8Array-like object is considered to be an artifact of an encoding or decoding bug and is treated like a Uint8Array, please add a dummy non-numerical key to bypass this behavior)\n- Uint8Array-like Array: first non-padding byte is  `1`\n- Integer positive number: first non-padding byte is `2`\n- Integer negative number: first non-padding byte is `3`\n- 0: first non-padding byte is `4`\n- NaN: first non-padding byte is `7`\n- Decimal number: first non-padding byte is `8`\n- Infinity: first non-padding byte is `9`\n- Array: first non-padding byte is `5`\n- JSON object or object with toJSON method: first non-padding byte is `5`\n- true: first non-padding byte is `6`\n- false: first non-padding byte is `6`\n- function: first non-padding byte is `10`\n- string or other: first non-padding byte is `254`\n- padding: padding bytes of `255` are added to the beginning of the returned Uint8Array until the specified length is reached, and the returned array will be truncated if the length of the returned array is larger than the specified length.\n\n**Returns:** Uint8Array (`Uint8Array(2) [1, 2]`) - the converted result as a Uint8Array\n\n### util.uint8ArrayToMixed\nConverts a Uint8Array back to an Array or any type (reverse of `util.mixedToUint8Array`)\n```javascript\nlet mixed1 = envoy.util.uint8ArrayToMixed(new Uint8Array([1, 2])); // [1, 2]\nlet mixed2 = envoy.util.uint8ArrayToMixed(new Uint8Array([255, 255, 255, 255, 255, 254, 116, 101, 115, 116]), true); // \"test\"\n```\n**Parameters:**\n- uint8Array (required): Uint8Array or Uint8Array-like array or Uint8Array-like object (`new Uint8Array([1, 2])`) - the Uint8Array to convert to a mixed object\n- includeType (optional, default: `false`): boolean (`false`) - whether to use the type of the original mixed object in the converted mixed object\n\n**Returns:** any (`[1, 2]`) - the converted result as an Array or any type\n\n### util.pack\nAlias of `util.mixedToUint8Array(mixed, true, length)`\n\n**Parameters:**\n- mixed (required): any (`[1, 2]`) - the mixed object to convert to a Uint8Array\n- length (optional, default: length of return array): number (`2`) - the length of the return array, used to add padding (includeType must be true to use the length argument)\n\n**Returns:** Uint8Array (`Uint8Array(2) [1, 2]`) - the converted result as a Uint8Array\n\n### util.unpack\nAlias of `util.uint8ArrayToMixed(mixed, true)`\n\n**Parameters:**\n- uint8Array (required): Uint8Array or Uint8Array-like array or Uint8Array-like object (`[1, 2]`) - the Uint8Array to convert to a mixed object\n\n**Returns:** any (`[1, 2]`) - the converted result as an Array or any type\n\n### util.objectEquals\nCheck whether two JSON objects are equal in almost constant time\n```javascript\nlet equals1 = envoy.util.objectEquals({\"t\": \"e\", \"s\": \"t\"}, {\"t\": \"e\", \"s\": \"t\"}); // true\nlet equals2 = envoy.util.objectEquals({\"t\": \"e\", \"s\": \"t\", \"i\": {\"n\": \"g\"}}, {\"i\": {\"n\": \"g\"}, \"s\": \"t\", \"t\": \"e\"}); // true\nlet equals3 = envoy.util.objectEquals({\"t\": \"e\", \"s\": \"t\", \"i\": {\"n\": \"g\"}}, {\"i\": {\"n\": \"g\"}, \"t\": \"e\"}); // false\nlet equals4 = envoy.util.objectEquals({\"i\": {\"n\": \"g\"}, \"t\": \"e\"}, {\"t\": \"e\", \"s\": \"t\", \"i\": {\"n\": \"g\"}}); // false\nlet equals5 = envoy.util.objectEquals({\"t\": \"e\", \"s\": \"t\", \"i\": {\"n\": \"g\"}}, {\"t\": \"e\", \"s\": \"t\", \"i\": {\"n\": \"o\"}}); // false\n```\n**Parameters:**\n- inputted (optional, default: `null`): object (`{\"t\": \"e\", \"s\": \"t\", \"i\": {\"n\": \"g\"}}`) - the user-inputted argument for comparison\n- original (optional, default: `null`): object (`{\"i\": {\"n\": \"g\"}, \"s\": \"t\", \"t\": \"e\"}`) - the stored argument to check the user-inputted argument against\n\n**Returns:** boolean (`true`) - whether the objects are equal (`==`) at every key and have the same keys\n\n### util.fixArmor\nInternal method used to fix the armored text on a `tEnvoyPGPKey`\n\n## Random\n\n### random.bytes\nGenerates cryptographically secure random bytes using any available cryptographically secure random number generator\n```javascript\n(async() =\u003e {\n\tlet random = await envoy.random.bytes(16); // Uint8Array(16) [104, 37, 240, 56, 174, 137, 249, 10, 46, 185, 52, 135, 172, 39, 150, 21]\n})();\n```\n**Parameters:**\n- length (optional, default: `1`): number (`16`) - the number of bytes to generate\n\n**Returns:** Promise fulfilling to Uint8Array (`Uint8Array(16) [104, 37, 240, 56, 174, 137, 249, 10, 46, 185, 52, 135, 172, 39, 150, 21]`) - the cryptographically secure random bytes\n\n**Note:** If tEnvoy cannot find any available cryptographically secure random number generator on the platform, you can replace this function **at your own risk** by assigning `envoy.random.bytes` to your own custom function. **`random.bytes` is used for all random bytes generation throughout tEnvoy. Do not replace this function unless you are a cryptography expert. If your custom function replacement is insecure, the entire security of tEnvoy will be compromised. We are not in any way responsible or liable for your modifications to tEnvoy.**\n\n### random.number\nGenerates a cryptographically secure random number using `random.bytes`\n```javascript\n(async() =\u003e {\n\tlet number = await envoy.random.number(0, 10); // 8.862745098039216\n})();\n```\n**Parameters:**\n- min (optional, default: `0`): number (`0`) - the minimum bound for the number\n- max (optional, default: `1`): number (`10`) - the maximum bound for the number\n\n**Returns:** Promise fulfilling to Decimal number (`8.862745098039216`) - a cryptographically secure random number between the specified minimum and maximum\n\n### random.string\nGenerates a cryptographically secure random string using `random.number`\n```javascript\n(async() =\u003e {\n\tlet string = await envoy.random.string(16); // HLONsJaTcCvI3vRD\n})();\n```\n**Parameters:**\n- length (optional, default: `10`): number (`16`) - the number of characters to generate\n\n**Returns:** Promise fulfilling to string (`HLONsJaTcCvI3vRD`) - a cryptographically secure random string of the specified length\n\n### random.words\nGenerates a cryptographically secure series of random words using `random.number` and the [BIP39 English wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt)\n```javascript\n(async() =\u003e {\n\tlet words = await envoy.random.words(4); // bright shield latin web\n})();\n```\n**Parameters:**\n- length (optional, default: `12`): number (`4`) - the number of words to generate\n\n**Returns:** Promise fulfilling to string (`bright shield latin web`) - a cryptographically secure series of the specified number of random words\n\n## Hashing\n\n### hash\nGet the deterministic hash using any hash function in tEnvoy (SHA-256, SHA-1, SHA-224, SHA-384, SHA-512, MD5, RIPEMD-160)\n```javascript\n(async() =\u003e {\n\tlet hash = await envoy.hash(\"test\", \"sha256\"); // 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\n})();\n```\n**Parameters:**\n- mixed (required): string or any - the value to hash (encoded into bytes for hashing through `util.mixedToUint8Array(mixed, false)`)\n- algorithm (optional, default: `\"sha256\"`): string - the algorithm to use\n\n**Algorithms:**\n- SHA-256 =\u003e `\"sha256\"`\n- SHA-1 =\u003e `\"sha1\"`\n- SHA-224 =\u003e `\"sha224\"`\n- SHA-384 =\u003e `\"sha384\"`\n- SHA-512 =\u003e `\"sha512\"`\n- MD5 =\u003e `\"md5\"`\n- RIPEMD-160 =\u003e `\"ripemd160\"`\n\n**Returns:** Promise fulfilling to string (`\"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\"`) - the hexadecimal representation of the deterministic hash of the specified input using the specified algorithm\n\n### hash.sha256\nGet the deterministic hash using the SHA-256 hash function\n```javascript\n(async() =\u003e {\n\tlet hash = await envoy.hash.sha256(\"test\"); // 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\n})();\n```\n**Parameters:**\n- mixed (required): string or any - the value to hash (encoded into bytes for hashing through `util.mixedToUint8Array(mixed, false)`)\n\n**Returns:** Promise fulfilling to string (`\"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\"`) - the hexadecimal representation of the deterministic hash of the specified input using the SHA-256 algorithm\n\n### hash.sha1\nGet the deterministic hash using the SHA-1 hash function\n```javascript\n(async() =\u003e {\n\tlet hash = await envoy.hash.sha1(\"test\"); // a94a8fe5ccb19ba61c4c0873d391e987982fbbd3\n})();\n```\n**Parameters:**\n- mixed (required): string or any - the value to hash (encoded into bytes for hashing through `util.mixedToUint8Array(mixed, false)`)\n\n**Returns:** Promise fulfilling to string (`\"a94a8fe5ccb19ba61c4c0873d391e987982fbbd3\"`) - the hexadecimal representation of the deterministic hash of the specified input using the SHA-1 algorithm\n\n**Warning: It is not recommended to use this method, as the SHA-1 algorithm has been broken.**\n\n### hash.sha224\nGet the deterministic hash using the SHA-224 hash function\n```javascript\n(async() =\u003e {\n\tlet hash = await envoy.hash.sha224(\"test\"); // 90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809\n})();\n```\n**Parameters:**\n- mixed (required): string or any - the value to hash (encoded into bytes for hashing through `util.mixedToUint8Array(mixed, false)`)\n\n**Returns:** Promise fulfilling to string (`\"90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809\"`) - the hexadecimal representation of the deterministic hash of the specified input using the SHA-224 algorithm\n\n### hash.sha384\nGet the deterministic hash using the SHA-384 hash function\n```javascript\n(async() =\u003e {\n\tlet hash = await envoy.hash.sha384(\"test\"); // 768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9\n})();\n```\n**Parameters:**\n- mixed (required): string or any - the value to hash (encoded into bytes for hashing through `util.mixedToUint8Array(mixed, false)`)\n\n**Returns:** Promise fulfilling to string (`\"768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9\"`) - the hexadecimal representation of the deterministic hash of the specified input using the SHA-384 algorithm\n\n### hash.sha512\nGet the deterministic hash using the SHA-512 hash function\n```javascript\n(async() =\u003e {\n\tlet hash = await envoy.hash.sha512(\"test\"); // ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff\n})();\n```\n**Parameters:**\n- mixed (required): string or any - the value to hash (encoded into bytes for hashing through `util.mixedToUint8Array(mixed, false)`)\n\n**Returns:** Promise fulfilling to string (`\"ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff\"`) - the hexadecimal representation of the deterministic hash of the specified input using the SHA-512 algorithm\n\n### hash.md5\nGet the deterministic hash using the MD5 hash function\n```javascript\n(async() =\u003e {\n\tlet hash = await envoy.hash.md5(\"test\"); // 098f6bcd4621d373cade4e832627b4f6\n})();\n```\n**Parameters:**\n- mixed (required): string or any - the value to hash (encoded into bytes for hashing through `util.mixedToUint8Array(mixed, false)`)\n\n**Returns:** Promise fulfilling to string (`\"098f6bcd4621d373cade4e832627b4f6\"`) - the hexadecimal representation of the deterministic hash of the specified input using the MD5 algorithm\n\n**Warning: It is not recommended to use this method, as the MD5 algorithm has been broken.**\n\n### hash.ripemd160\nGet the deterministic hash using the RIPEMD-160 hash function\n```javascript\n(async() =\u003e {\n\tlet hash = await envoy.hash.ripemd160(\"test\"); // 5e52fee47e6b070565f74372468cdc699de89107\n})();\n```\n**Parameters:**\n- mixed (required): string or any - the value to hash (encoded into bytes for hashing through `util.mixedToUint8Array(mixed, false)`)\n\n**Returns:** Promise fulfilling to string (`\"5e52fee47e6b070565f74372468cdc699de89107\"`) - the hexadecimal representation of the deterministic hash of the specified input using the RIPEMD-160 algorithm\n\n## Key Factory\n\n### keyFactory.pbkdf2\nGenerates a key of a certain size from a password and salt through a certain number of rounds through PBKDF2-HMAC-SHA256 (Password-Based Key Derivation Function 2 with SHA-256 Hash-based Message Authentication Code)\n```javascript\n(async() =\u003e {\n\tlet bytes = await envoy.keyFactory.pbkdf2(\"password\", \"salt\", 150000, 32); // Uint8Array(32) [149, 196, 67, 208, 74, 43, 94, 32, 74, 46, 127, 61, 91, 212, 249, 168, 6, 120, 30, 15, 29, 198, 125, 130, 53, 250, 186, 249, 187, 224, 180, 201]\n})();\n```\n**Parameters:**\n- password (required): string or any - the password to use to generate the key (encoded into bytes for key generation through `util.mixedToUint8Array(password, false)`)\n- salt (required): string or any - the salt to use to generate the key (encoded into bytes for key generation through `util.mixedToUint8Array(salt, false)`)\n- rounds (optional, default: `150000`): number - the number of rounds to use to generate the key\n- size (optional, default: `32`): number - the size of the key in bytes\n\n**Returns:** the key generated from the specified parameters using PBKDF2-HMAC-SHA256\n\n### keyFactory.genSeedFromCredentials\nAlias of `keyFactory.pbkdf2(password, username, rounds, size)`\n\n**Parameters:**\n- username (required): string or any - the salt to use to generate the key (encoded into bytes for key generation through `util.mixedToUint8Array(username, false)`)\n- password (required): string or any - the password to use to generate the key (encoded into bytes for key generation through `util.mixedToUint8Array(password, false)`)\n- rounds (optional, default: `150000`): number - the number of rounds to use to generate the key\n- size (optional, default: `32`): number - the size of the key in bytes\n\n**Returns:** the key generated from the specified parameters using PBKDF2-HMAC-SHA256\n\n### keyFactory.genPGPKeys\nGenerates an asymmetrical PGP key\n```javascript\n(async() =\u003e {\n\tlet keys = await envoy.keyFactory.genPGPKeys(); // {privateKey: tEnvoyPGPKey, publicKey: tEnvoyPGPKey}\n})();\n```\n\n### keyFactory.genPGPSymmetricKey\nGenerates a symmetrical PGP key\n```javascript\n(async() =\u003e {\n\tlet key = await envoy.keyFactory.genPGPSymmetricKey({key: \"test\"}) // tEnvoyPGPKey {...}\n})();\n```\n\n### keyFactory.genNaClKeys\nGenerates an asymmetrical NaCl key\n```javascript\n(async() =\u003e {\n\tlet keys = await envoy.keyFactory.genNaClKeys(); // {privateKey: tEnvoyNaClKey, publicKey: tEnvoyNaClKey, privateSigningKey: tEnvoyNaClSigningKey, publicSigningKey: tEnvoyNaClSigningKey}\n})();\n```\n\n### keyFactory.genNaClSymmetricKey\nGenerates a symmetrical NaCl key\n```javascript\n(async() =\u003e {\n\tlet key = await envoy.keyFactory.genNaClSymmetricKey({key: \"test\"}); // tEnvoyNaClKey {...}\n})();\n```\n\n## PGP Keys\n\n### constructor\n\n### tEnvoyPGPKey.destroy\n\n### tEnvoyPGPKey.toString\n\n### tEnvoyPGPKey.getType\n\n### tEnvoyPGPKey.getPasswordProtected\n\n### tEnvoyPGPKey.setPasswordProtected\n\n### tEnvoyPGPKey.getId\n\n### tEnvoyPGPKey.getKey\n\n### tEnvoyPGPKey.getPrivate\n\n### tEnvoyPGPKey.setPrivate\n\n### tEnvoyPGPKey.getPrivateArmored\n\n### tEnvoyPGPKey.setPrivateArmored\n\n### tEnvoyPGPKey.getPublic\n\n### tEnvoyPGPKey.setPublic\n\n### tEnvoyPGPKey.getPublicArmored\n\n### tEnvoyPGPKey.setPublicArmored\n\n### tEnvoyPGPKey.encrypt\n\n### tEnvoyPGPKey.decrypt\n\n### tEnvoyPGPKey.sign\n\n### tEnvoyPGPKey.verify\n\n### tEnvoyPGPKey.toPublic\n\n## NaCl Keys\n\n### constructor\n\n### tEnvoyNaClKey.destroy\n\n### tEnvoyNaClKey.toString\n\n### tEnvoyNaClKey.getType\n\n### tEnvoyNaClKey.getPasswordProtected\n\n### tEnvoyNaClKey.setPasswordProtected\n\n### tEnvoyNaClKey.getPrivate\n\n### tEnvoyNaClKey.setPrivate\n\n### tEnvoyNaClKey.getPublic\n\n### tEnvoyNaClKey.setPublic\n\n### tEnvoyNaClKey.backup\n\n### tEnvoyNaClKey.fromBackup\n\n### tEnvoyNaClKey.encrypt\n\n### tEnvoyNaClKey.decrypt\n\n### tEnvoyNaClKey.encryptEphemeral\n\n### tEnvoyNaClKey.decryptEphemeral\n\n### tEnvoyNaClKey.genSigningKeys\n\n### tEnvoyNaClKey.genSharedKey\n\n### tEnvoyNaClKey.toPublic\n\n## NaCl Signing Keys\n\n### constructor\n\n### tEnvoyNaClSigningKey.destroy\n\n### tEnvoyNaClSigningKey.toString\n\n### tEnvoyNaClSigningKey.getType\n\n### tEnvoyNaClSigningKey.getPasswordProtected\n\n### tEnvoyNaClSigningKey.setPasswordProtected\n\n### tEnvoyNaClSigningKey.getPrivate\n\n### tEnvoyNaClSigningKey.setPrivate\n\n### tEnvoyNaClSigningKey.getPublic\n\n### tEnvoyNaClSigningKey.setPublic\n\n### tEnvoyNaClSigningKey.backup\n\n### tEnvoyNaClSigningKey.fromBackup\n\n### tEnvoyNaClSigningKey.sign\n\n### tEnvoyNaClSigningKey.verify\n\n### tEnvoyNaClSigningKey.verifyWithMessage\n\n### tEnvoyNaClSigningKey.toPublic\n\n# Cryptography Notice\nThis distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.\n\nThe U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftogatech%2Ftenvoy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftogatech%2Ftenvoy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftogatech%2Ftenvoy/lists"}