Giter VIP home page Giter VIP logo

rsa-example's Introduction

Getting Started

First, you will need to generate a private and public key-pair. You can do so using the following commands:

# Private Key
openssl genrsa -out private-key-name.pem 3072
# Public Key
openssl rsa -in private-key-name.pem -pubout -out public-key-name.pem

You can customize the key to better suit your needs, but keep in mind you'll have to modify the settings in the keyConfig constant in the /utils/rsa.ts file.

Then you will need to set the keys into environment files. The private key goes to the backend, and the public key goes to the frontend.

In this project, you can duplicate the .env.local.example file and rename it to .env.local.

In your env files, use double-quotes around the variable's value to support the \n character, place a \n at the end of each line, and then reduce the whole key into a single line, like so:

-----BEGIN RSA PRIVATE KEY-----\nFiRsTlInE\nSeCoNdLiNe\nThIrDlInE\nSoOnAnDSoFoRtH\n-----END RSA PRIVATE KEY-----

There is an .env.local.example file with an example to help you understand, along with an example pair of keys.

The example keys will work, but you OUGHT to change them for a newly generated pair when implementing this.

Finally, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

If you see the name John Doe, the signature and verification worked properly. If you try to modify this data after it was signed, or before it is verified, an error will appear.

rsa-example's People

Contributors

matpk avatar

Stargazers

João Neto avatar  avatar Nicolas G avatar 快乐的小萌新 avatar Des Histoires à Petits Pas avatar Venkatesh KL avatar Marco Attia avatar egolege avatar  avatar Ronye Vernaes avatar Saleumsack Keoboualay avatar Germain H. avatar Moa Torres avatar leob avatar  avatar Sarah Siqueira avatar LilPimpn86 avatar Kyle Chamberlain avatar  avatar Serhii Lytvyn avatar Dylan Archer avatar Dan Gavriliu avatar  avatar Hammed Oyedele avatar  avatar Leela Anuroop A avatar Dimitri Masson avatar leokazuyukinagatani avatar Abdul Fattah Ikhsan avatar Rui Domingues avatar Heitor Carmo avatar Britivaldo Neto avatar Luan Cardoso avatar  avatar  avatar Wallace Júnior avatar Ezio Lemes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.