Skip to content

Latest commit

 

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Encryption test & samples

  • This project is used as a template for the encryption applications in a WEB API.
  • The server will be performing encrypt/decrypt methods for some kind of text messages.

Dependencies

References


Install Instructions

  1. Clone the project in your machine.
git clone https://github.com/AlfonsoG-dev/EncryptionSamples
  1. Install node dependencies.
npm i
  1. Configure database by creating the connection file and class using the following example.
import mysql2 from "mysql2"
import { configDotenv } from "dotenv"
configDotenv()
export default class DBConfig {
    db_name
    constructor() {
        this.db_name = "database_name"
    }

    get config() {
        return {
            host: "localhost",
            port: "3306",
            user: "",
            password: process.env.DB_PASSWORD,
            database: this.db_name
        }
    }
    get cursor() {
        return mysql2.createConnection(this.config)
    }
}

for the database you will find a script to build the tables in the SQL folder.

  • you only need to source it in the mysql server CLI.
cd ./sql/
mysql -u root -p
mysql > source script.sql;
  1. Create the environment variables.
NODE_ENV='development' -- if you want to test locally otherwise use **production**
DB_PASSWORD=#database password
API_PORT='3000' --port for the server
API_HOST='127.0.0.1' -- IP also you can use **localhost**
PASSPHRASE=#secure phrase for secret key generation
SECRET_KEY=#use the encrypt methods to generate
IV=#use the encrypt methods to generate

Usage instructions

  1. Create a user for the API.
  2. Run the API.
npm start
  1. Make HTTP requests to the API end-points.

the server is running in the port: 3000

  • Create the first user for testing and message for testing
POST http://localhost:3000/user/post-user
Content-Type: application/json

{
    "email": "test@gmail.com",
    "alias": "test",
    "password": "123asd"
}
POST http://localhost:3000/message/post-message
Content-Type: application/json

{
    "user_id_fk": 1,
    "head": "test message",
    "body": "this is a test message"
}
  1. Execute test.
npm run test

Disclaimer

  • This project its for educational purposes.
  • Security issues are not taken into account.
  • Use at your own risk.

About

This proyect is for testing symmetric & asymmetric encryption

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages