Giter Site home page Giter Site logo

cipher's Introduction

simple utility for RSA/AES encryption and decryption

Table of Contents

porpuse

simple utility for RSA/AES encryption and decryption.

preparation

  1. requires Python 3.5 or newer version
  2. requires 3rd-party modules, e.g. pycryptodome
    pip install -r equirements.txt
    
  3. generate RSA key pair: id_rsa (priviate key) and  id_rsa.pub (public key)
    ssh-keygen -t rsa -C "your-comments"
    ls ~/.ssh
    $ authorized_keys  id_rsa  id_rsa.pub  known_hosts
    
  4. register public key to ~/.ssh/authorized_keys in remote host
    ssh-copy-id -i id_rsa.pub [email protected]
    

example

RSA

encryption using default public key (~/.ssh/id_rsa.pub)

# encrypt string
$ echo abcd | ./cipher.py rsa-e
lRMjlpn0DMd1yBAPz888A+dxsBy6dJ6IjIPe5h+sZ/Hwgu+8z8a75iEJabYEsFFsi3e11ffB0pKikMCPY+NqknqkRz6eQBaM9AMrgDkI088L81mTD4YT+LCgGWqZvDA+xLy4sSkx+B78ASVEWYAWwDxra3A/HJ/WQE+TR05rZq7ufcbY7b5aztVNjFYvv1aiAyjd6KQl6bzBdD2uJlfinKkgnBKdeciePKI3pNmUVQlW7Cwiwy8QSqgx/ldNHekUt+IWdUN1AL1ISJpFFpOpTSXBgu+BSPqBxb5Erc4FRP0p8OiYdZ7tF8fj2RRLy2AlQkrDpH1AC/cRKOw33T+1wA==

# encrypt string
$ echo abcd | ./cipher.py rsa-e > encrypted_text

# encrypt a file
$ ./cipher.py rsa-e test.txt
cw/3rm/jFvhLm3NBgxGXocze6KFdX3vcVVxiRLI7/dXWd2R0WyvuRpbZgPZ1Y8JxZWAF+vSDO9B5aOcodPCdARUAbWQqomy8rwzw8X7HNU7EHsEF6AIoNRrJYEG1ZWjURh8fn6i/85zTS4W7OnOxkYGrTt/lADDoFq3I1Q4BcZt/q+6E+KtOPGekxXTHC1jH3ZVntTo0xuc5puJpTkS0WuKLHlh+gMMv0USq3XUmRH3U8onS/1dMBSAfIEcfNHFBgDAnKwszDS/ABnJCt3wfdQpRq8o4gk+3yDFHX8HFTQWi6RAa9ClyFjdIvQK1gJDDmejEzGpe554loRPF733l6w==

# encrypt a file to binary file
$ ./cipher.py rsa-e test.txt -o encrypted.bin

decryption using default private key (~/.ssh/id_rsa)

# decrypt string from pipe
$ cat encrypted_text | ./cipher.py rsa-d
abcd

# decrypt a file
$ ./cipher.py rsa-d encrypted_text
abcd

encryption using specific private/public key

$ echo abcd | cipher.py rsa-e -k ./id_rsa.pub > encrypted_text

decryption using specific private key

$ ./cipher.py rsa-d -k ./id_rsa encrypted_text
abcd

AES

# encrypt to base64 string
$ echo abcd | ./cipher.py aes-e --password 12345678
dYKyXAVZBj2aDTXGN50EMLUz4Ypj4+P8ePFUKurPfLe89uXZAQ==

# decrypt from base64 string
$ echo dYKyXAVZBj2aDTXGN50EMLUz4Ypj4+P8ePFUKurPfLe89uXZAQ== | ./cipher.py aes-d --password 12345678
abcd

# encrypt to binary file
$ ./cipher.py aes-e --password 12345678 input.file -o encrypted.file

# decrypt from binary file
$ ./cipher.py aes-d --password 12345678 encrypted.file -o decrypted.file

cipher's People

Contributors

hhk0571 avatar

Watchers

James Cloos 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.