{"id":23665866,"url":"https://github.com/alfonsog-dev/encryptionsamples","last_synced_at":"2025-12-08T11:30:14.364Z","repository":{"id":261707079,"uuid":"885095737","full_name":"AlfonsoG-dev/EncryptionSamples","owner":"AlfonsoG-dev","description":"This proyect is for testing symmetric \u0026 asymmetric encryption","archived":false,"fork":false,"pushed_at":"2024-12-02T04:05:19.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-29T06:18:12.194Z","etag":null,"topics":["api-rest","backend-api","encryption-decryption"],"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/AlfonsoG-dev.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":"2024-11-08T00:19:08.000Z","updated_at":"2024-12-02T04:05:23.000Z","dependencies_parsed_at":"2024-11-27T14:16:08.184Z","dependency_job_id":null,"html_url":"https://github.com/AlfonsoG-dev/EncryptionSamples","commit_stats":null,"previous_names":["alfonsog-dev/encryptionsamples"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlfonsoG-dev%2FEncryptionSamples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlfonsoG-dev%2FEncryptionSamples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlfonsoG-dev%2FEncryptionSamples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlfonsoG-dev%2FEncryptionSamples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlfonsoG-dev","download_url":"https://codeload.github.com/AlfonsoG-dev/EncryptionSamples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239665927,"owners_count":19677043,"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":["api-rest","backend-api","encryption-decryption"],"created_at":"2024-12-29T06:18:24.863Z","updated_at":"2025-12-08T11:30:14.308Z","avatar_url":"https://github.com/AlfonsoG-dev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Encryption test \u0026 samples\n- This project is used as a template for the encryption applications in a WEB API.\n- The server will be performing encrypt/decrypt methods for some kind of text messages.\n\n# Dependencies\n- [node_20.18.0](https://nodejs.org/en/download/package-manager)\n- [mysql_server_8.0.34](https://dev.mysql.com/downloads/)\n\n# References\n- [asymmetric_encryption](https://medium.com/@makenoizee/secure-data-transmission-with-node-js-and-asymmetric-encryption-20b2d80aa871)\n- [symmetric_encryption](https://dev.to/superviz/implementing-symmetric-and-asymmetric-encryption-with-nodejs-4efp)\n- [about asymmetric encryption](https://www.cloudflare.com/es-es/learning/ssl/what-is-asymmetric-encryption/)\n- [node_documentation](https://nodejs.org/docs/latest/api/)\n- [mysql_CLI_documentation](https://dev.mysql.com/doc/refman/8.4/en/mysql.html)\n- [mocha_testing_documentation](https://mochajs.org/#getting-started)\n- [assert_documentation](https://www.w3schools.com/nodejs/ref_assert.asp)\n\n----\n\n# Install Instructions\n1. Clone the project in your machine.\n```shell\ngit clone https://github.com/AlfonsoG-dev/EncryptionSamples\n```\n2. Install **node** dependencies.\n```shell\nnpm i\n```\n3. Configure **database** by  creating the connection file and class using the following example.\n```js\nimport mysql2 from \"mysql2\"\nimport { configDotenv } from \"dotenv\"\nconfigDotenv()\nexport default class DBConfig {\n    db_name\n    constructor() {\n        this.db_name = \"database_name\"\n    }\n\n    get config() {\n        return {\n            host: \"localhost\",\n            port: \"3306\",\n            user: \"\",\n            password: process.env.DB_PASSWORD,\n            database: this.db_name\n        }\n    }\n    get cursor() {\n        return mysql2.createConnection(this.config)\n    }\n}\n```\n\u003e for the database you will find a script to build the tables in the **SQL** folder.\n\u003e- you only need to source it in the **mysql server CLI**.\n```shell\ncd ./sql/\nmysql -u root -p\nmysql \u003e source script.sql;\n```\n4. Create the environment variables.\n```env\nNODE_ENV='development' -- if you want to test locally otherwise use **production**\nDB_PASSWORD=#database password\nAPI_PORT='3000' --port for the server\nAPI_HOST='127.0.0.1' -- IP also you can use **localhost**\nPASSPHRASE=#secure phrase for secret key generation\nSECRET_KEY=#use the encrypt methods to generate\nIV=#use the encrypt methods to generate\n```\n\n# Usage instructions\n1. Create a user for the API.\n2. Run the API.\n```shell\nnpm start\n```\n3. Make **HTTP** requests to the API **end-points**.\n\u003e the server is running in the port: **3000**\n\u003e- Create the first user for testing and message for testing\n```http\nPOST http://localhost:3000/user/post-user\nContent-Type: application/json\n\n{\n    \"email\": \"test@gmail.com\",\n    \"alias\": \"test\",\n    \"password\": \"123asd\"\n}\nPOST http://localhost:3000/message/post-message\nContent-Type: application/json\n\n{\n    \"user_id_fk\": 1,\n    \"head\": \"test message\",\n    \"body\": \"this is a test message\"\n}\n```\n4. Execute test.\n```shell\nnpm run test\n```\n-----\n# Disclaimer\n- This project its for educational purposes.\n- Security issues are not taken into account.\n- Use at your own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfonsog-dev%2Fencryptionsamples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falfonsog-dev%2Fencryptionsamples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfonsog-dev%2Fencryptionsamples/lists"}