Giter VIP home page Giter VIP logo

aes-encrypt's Introduction

aes-encrypt

A simple command line tool for AES encryption and decryption.

Workflow:

flowchart
    Pwd[Password]
    Msg[Message]
    Key(Pbkdf2 Key)
    RS[Random Salt]
    Enc(Encrypted Data)
    IV[Random IV]

    Pwd -->|generate| Key
    RS -->|generate| Key
    Msg --> |AES-256-CBC| Enc
    Key --> |AES-256-CBC| Enc
    IV --> |AES-256-CBC| Enc

Usage

To encrypt a message, type:

$ node aes.mjs encrypt my-secret.json

Enter password:

password: hello12345

Then type messages:

type messages (type EOF to end):
Hello, this is a secret file!
Using AES encryption!
EOF

When EOF entered the message was end, and the encrypted data saved as JSON file:

encrypted data saved: my-secret.json
{
  "hash-alg": "sha256",
  "message-iv-hash": "2fb92934a7b17cafef3a5e29212b0bd73ee035d80294bdaa16fdeb34742eaa46",
  "encrypt-alg": "aes-256-cbc",
  "encrypt-iv": "31d09b20a0fce0ab572653b41c7fba56",
  "encrypt-data": "48f307ba5b51fc73c4843ec6524ee07b239d9e0d7af76cfec2affaf5035a3d0534f67d7643872f143eebd2abbc9e27bb81f0383b5d1f5c132b0d8afa194c56dd",
  "pbkdf2-salt": "923a3c3f1372cf7b9cdc254473a1ee4e64b33fa07fc32130e6dbc40199b04326",
  "pbkdf2-iterations": 999999
}

To decrypt a message, type:

$ node aes.mjs decrypt my-secret.json 

Enter password:

password: hello12345

If password is correct, the decrypted message is display:

Decrypted ok:
Hello, this is a secret file!
Using AES encryption!

Notes

Both the password and message are input by keyboard in terminal, and never saved into file.

The saved encrypted JSON file can be safely backed up.

aes-encrypt's People

Contributors

michaelliao 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.