Skip to content

Instantly share code, notes, and snippets.

@krisf
Last active June 4, 2024 12:17
Show Gist options
  • Save krisf/5391210 to your computer and use it in GitHub Desktop.
Save krisf/5391210 to your computer and use it in GitHub Desktop.

Revisions

  1. krisf revised this gist Apr 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion enc
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash
    #encrypt files with aes-256-cbc cipher using openssl
    #install:
    # sudo wget -O /usr/bin/enc http://gist.github.com/krisf/5391210/raw/1de20acd281c644e9ada44a88cab26d802640804/enc
    # sudo wget -O /usr/bin/enc https://gist.github.com/krisf/5391210/raw/4a105a6b8f98f39e9e74a1dd2a78ef6f631acdb1/enc
    # sudo chmod +x /usr/bin/enc
    # enc --help

  2. krisf revised this gist Apr 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion enc
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash
    #encrypt files with aes-256-cbc cipher using openssl
    #install:
    # sudo curl https://gist.github.com/krisf/5391210/raw/1de20acd281c644e9ada44a88cab26d802640804/enc > /usr/bin/enc
    # sudo wget -O /usr/bin/enc http://gist.github.com/krisf/5391210/raw/1de20acd281c644e9ada44a88cab26d802640804/enc
    # sudo chmod +x /usr/bin/enc
    # enc --help

  3. krisf revised this gist Apr 15, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions enc
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    #!/bin/bash
    #encrypt files with aes-256-cbc cipher using openssl
    #install:
    # sudo curl https://gist.github.com/krisf/5391210/raw/1de20acd281c644e9ada44a88cab26d802640804/enc > /usr/bin/enc
    # sudo chmod +x /usr/bin/enc
    # enc --help

    #encrypt files
    if [ $1 == "-e" ];
  4. krisf created this gist Apr 15, 2013.
    31 changes: 31 additions & 0 deletions enc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/bin/bash
    #encrypt files with aes-256-cbc cipher using openssl

    #encrypt files
    if [ $1 == "-e" ];
    then
    if [ -f "$2" ];
    then
    openssl aes-256-cbc -a -e -salt -in "$2" -out "$2.aes"
    else
    echo "This file does not exist!"
    fi
    #decrypt files
    elif [ $1 == "-d" ];
    then
    if [ -f "$2" ];
    then
    openssl aes-256-cbc -a -d -salt -in "$2" -out "$2.decrypt"
    else
    echo "This file does not exist!"
    fi
    #show help
    elif [ $1 == "--help" ];
    then
    echo "This software uses openssl for encrypting files with the aes-256-cbc cipher"
    echo "Usage for encrypting: ./encrypt -e [file]"
    echo "Usage for decrypting: ./encrypt -d [file]"
    else
    echo "This action does not exist!"
    echo "Use ./encrypt --help to show help."
    fi