{"id":24793107,"url":"https://github.com/zhenglinlei/encrypt-charcode-num-v2","last_synced_at":"2025-10-10T04:39:58.831Z","repository":{"id":135115372,"uuid":"479111885","full_name":"ZhengLinLei/encrypt-charcode-num-v2","owner":"ZhengLinLei","description":"Encrypt strings and passwords with dynamic key","archived":false,"fork":false,"pushed_at":"2022-10-28T10:08:24.000Z","size":110,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T22:02:08.680Z","etag":null,"topics":["algorithms","code"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZhengLinLei.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}},"created_at":"2022-04-07T18:54:32.000Z","updated_at":"2023-05-14T20:42:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"a8297fcd-e32a-4920-b311-0b6d225826af","html_url":"https://github.com/ZhengLinLei/encrypt-charcode-num-v2","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/ZhengLinLei%2Fencrypt-charcode-num-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2Fencrypt-charcode-num-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2Fencrypt-charcode-num-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2Fencrypt-charcode-num-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZhengLinLei","download_url":"https://codeload.github.com/ZhengLinLei/encrypt-charcode-num-v2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245315295,"owners_count":20595217,"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":["algorithms","code"],"created_at":"2025-01-29T21:56:01.365Z","updated_at":"2025-10-10T04:39:58.750Z","avatar_url":"https://github.com/ZhengLinLei.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Encrypt.js v2 [![Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n\nThis is an extended version of [https://github.com/ZhengLinLei/encrypt-charcode-num](https://github.com/ZhengLinLei/encrypt-charcode-num) repository, please read the basic documentation before using this repo and check the new functionalities that have been added in this version.\n\n## How it does work?\n\nInputs needed\n1. Key [ Arr(Int) | Str ]\n2. Text [ Str | Int ]\n3. Alphabet [ Arr(Str) ] (Optional)\n\n\n![IMAGE](./doc/info.png)\n\n\n# Javascript use\n\nFile script `script.js`. You can add it by `html` or with `node`\n```html\n\u003cscript src=\"./src/script.js\"\u003e\u003c/script\u003e\n```\n\nIf you are going to use `node`, please remove the comment from the main script file, in the last line.\n\n## Table of content\n\n1. [KeyStr()](#keystr)\n    * [Change key](#change-key)\n    * [Encrypt content](#encrypt)\n    * [Dencrypt content](#dencrypt)\n    * [Import charcode list](#importlist)\n    * [Examples of code](#example)\n2. [OwnCharList()](#ownchar)\n    * [Parameters](#param)\n    * [Create own list](#ownlist)\n3. [Examples](#code)\n\n## 1. \u003ca name=\"keystr\"\u003e\u003c/a\u003e new KeyStr(:key, :str)\n\nFirst need to init a variable\n```javascript\nlet ClassChar = new KeyStr([...])\n```\n\nThe class need two parameters.\n1. Key [Str]\n2. Split [Str] : Default = ','\n```javascript\nlet ClassChar = new KeyStr('10|30|11', '|') // SPLIT THE TEXT WITH '|'\n```\n\n### 1.1. \u003ca name=\"change-key\"\u003e\u003c/a\u003e Change key\n\nIf you want to change the key, you can do it with `changeKey()` method.\n```javascript\nlet ClassChar = new KeyStr('10|30|11', '|') // SPLIT THE TEXT WITH '|'\n\nClassChar.changeKey('2,8', ',') // THIS MUST CHANGE THE KEY FROM [10, 30, 11] TO [2, 8]\n```\n\n### 1.2. \u003ca name=\"encrypt\"\u003e\u003c/a\u003e Encrypt content\n\nThe `encryptStr()` method help you to encrypt the text, there a two ways to encrypt. One by temporal key or with the key that was initialized.\n```javascript\nlet ClassChar = new KeyStr('10|30|11', '|') // SPLIT THE TEXT WITH '|'\n\nClassChar.changeKey('2,8', ',') // THIS MUST CHANGE THE KEY FROM [10, 30, 11] TO [2, 8]\n// IN THIS CASES WILL USE THE KEY INIALIZATED BEFORE\n// key = [2, 8]\n\nconsole.log(ClassChar.encryptStr('Hello'))\n// Return: Jmntq\n\n// ====================================\n\n// OR YOU CAN USE THE TEMPORAL KEY\n// THE SYNTAX MUST BE\n// [str, split]\n\nconsole.log(ClassChar.encryptStr('Hello', ['8|3|1', '|']))\n// Return: Phmtr\n\n```\n\n### 1.2. \u003ca name=\"dencrypt\"\u003e\u003c/a\u003e Dencrypt content\n\nAnd if you want to dencrypt you can do it with `dencryptStr()` method, there a two ways to encrypt. One by temporal key or with the key that was initialized.\n```javascript\nlet ClassChar = new KeyStr('10|30|11', '|') // SPLIT THE TEXT WITH '|'\n\nClassChar.changeKey('2,8', ',') // THIS MUST CHANGE THE KEY FROM [10, 30, 11] TO [2, 8]\n// IN THIS CASES WILL USE THE KEY INIALIZATED BEFORE\n// key = [2, 8]\n\nconsole.log(ClassChar.dencryptStr('Jmntq'))\n// Return: Hello\n\n// ====================================\n\n// OR YOU CAN USE THE TEMPORAL KEY\n// THE SYNTAX MUST BE\n// [str, split]\n\nconsole.log(ClassChar.dencryptStr('Phmtr', ['8|3|1', '|']))\n// Return: Hello\n\n```\n\n### 1.4. \u003ca name=\"importlist\"\u003e\u003c/a\u003e Import charcode list\n\nIf you want to use another charcode list apart from the default (utf-7) ASCII list or your own list, jump to the [OwnCharList()](#ownchar) section and then continue reading this part.\n\n```javascript\nlet CharVar = new KeyStr('1,3,4');\n\n// Let's create a different charcode list\nlet AlphabetA = new OwnCharList('utf-16'); // UTF-16\n\n// Import the Alphabet\nCharVar.importCharList(AlphabetA);\nconsole.log(CharVar.encryptStr('Hello world!'));\n// Ihpmr$xrvmg%\nconsole.log(CharVar.dencryptStr('Ihpmr$xrvmg%'));\n// Hello world!\n\n\n// Now let's create an own charcode list\nlet AlphabetB = new OwnCharList('own'); // Own list\nlet ownlist = ['b', 'a', 'c', 'd', 'f', 'e', 'g', 'l', 'w', 'h', 'j', 's', 'i', 'o', 'r', ' '];\nAlphabetB.createList(ownlist);\n\nCharVar.importCharList(AlphabetB);\nconsole.log(CharVar.encryptStr('world', ['4 5 3', ' ']));\n// icasw\nconsole.log(CharVar.dencryptStr('icasw', ['4 5 3', ' ']));\n// world\n```\n\n\n### 1.5. \u003ca name=\"example\"\u003e\u003c/a\u003e Examples of code\n\n```javascript\nlet CharVar = new KeyStr('0')\n\nconsole.log(CharVar.encryptStr('Hello world!', ['20 10 30', ' ']))\n// \\oy\u003eyn?\n\nconsole.log(CharVar.dencryptStr('\\oy\u003eyn?', ['20 10 30', ' ']))\n// Hello world!\n```\n\n## 2. \u003ca name=\"ownchar\"\u003e\u003c/a\u003e new OwnCharList(:type)\n\n```javascript\nlet Alphabet = new OwnCharList([...]);\n```\n\n### 2.1. \u003ca name=\"param\"\u003e\u003c/a\u003e Parameters\n\nThe paramateres allowed are\n```js\n/* ===========\n        type: ['utf-7', 'utf-8', 'utf-16', 'utf-32', 'own']\n\n        Default: 'utf-7'\n============= */\n\nlet AlphabetA = new OwnCharList('utf-32');\n\n\n// And the own charlist\nlet AlphabetB = new OwnCharList('own');\n// After declared the variable, create the list\n```\n\n### 2.2. \u003ca name=\"ownlist\"\u003e\u003c/a\u003e Create Own List\n\n```js\n// And the own charlist\nlet AlphabetB = new OwnCharList('own');\n// After declared the variable, create the list\n\nlet charlist = 'asdfghjklqwertyuiopzxcvbnm'.split('');\nAlphabetB.createList(charlist);\n\n\n// Import the Alphabet to Encrypter\nlet Encode = new KeyStr([0, 2, 1]);\nEncode.importCharList(AlphabetB);\n```\n\n\n## 3. \u003ca name=\"code\"\u003e\u003c/a\u003e Example\n```js\nlet CharVar = new KeyStr('0');\n\n// let Chacode = new OwnCharList('utf-8');\n\nlet ownlist = 'abcde'.split('');\n// let ownlist = ['b', 'a', 'c', 'd', 'f', 'e', 'g', 'l', 'w', 'h', 'j', 's', 'i', 'o', 'r', ' '];\nlet Charcode = new OwnCharList('own');\nCharcode.createList(ownlist);\n\nCharVar.importCharList(Charcode);\n\nconsole.log(CharVar.encryptStr('e', ['13 8', ' ']));\nconsole.log(CharVar.dencryptStr('c', ['13 8', ' ']), CharVar.charList.range);\n```\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n# Fix some bugs\n\nIf you are using terminal to debugging, in some cases the text doesn't be displayed correctly, like `` or some other characters.\n\n### How to fix it?\n\nUse your browser console for debugging, and will display some characters were in terminal doesn't be displayed.\n\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n### Love this repo? Give us a star ⭐\n\n\u003ca href=\"./\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Encrypt%20charcode%20num-Rate-blue\"\u003e\n\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhenglinlei%2Fencrypt-charcode-num-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhenglinlei%2Fencrypt-charcode-num-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhenglinlei%2Fencrypt-charcode-num-v2/lists"}