User Controls

Ever need to encrypt something quick and easy?

  1. #1
    Sophie Pedophile Tech Support
    If i can't be bothered with veracrypt because it will take forever and encryptpad is just a hassle. I simply use OpenSSL fom the terminal, but typing out commands is a hassle again. So what i will do is write multiple scripts for things i need to automate often and keep those updated and optimize them every now and then.

    I thought you might be interested in my latest iteration of quick encryption script.


    EDIT: Whoops forgot an echo, fixed.
    EDIT2: Debugging, it's good practice.

    #!/bin/bash

    ESC="\x1b["
    RESET=$ESC"39;49;00m"
    RED=$ESC"31;01m"

    # Generate random password of arbitrary length
    generate(){
    follow_up=$1
    clear && echo -e "Generate Random Password"

    echo -e "\nAmount of characters in generated password?"
    read -p "[Integer]: " amount

    sleep 0.5 clear

    cat /dev/random | LC_ALL=C tr -dc 'a-zA-Z0-9' | head -c$amount

    echo -e "Your randomly generated password is: $amount"
    echo -e "Do not lose it!"
    read -p "Enter any button to resume..." null

    if [[ follow_up == "true" ]]; then encode; fi

    };

    # Encoding ops
    encode(){
    clear && echo -e "Encode File\n"
    read -p 'File: ' infile
    echo -e 'Password: \n'
    read -s password
    openssl enc -aes256 -e -k $password -pbkdf2 -in '$infile' -out '$infile.enc'
    openssl enc -a -in $infile -out '$infile.enc.pem'

    echo -e "\nDone!\n" && sleep 1.5
    exit 0

    };

    # Decoding ops
    decode(){
    clear && echo -e "Decode File\n"
    read -p 'File: ' infile
    echo -e 'Password: \n'
    read -s password
    openssl enc -d -aes256 -k $password -pbkdf2 -in '$infile.enc' -out '$infile.b64'
    read -p 'Outfile format ' outfile
    openssl enc -a -d -in '$infile.b64' -out $outfile

    echo -e "\nDone!\n" && sleep 1.5
    exit 0
    };


    # Parse CLI
    if [[ "$1" != "" ]]; then
    case $1 in
    '-e' | '--encode' )
    encode
    esac

    elif [[ "$1" != "" ]]; then
    case $1 in
    '-d' | '--decode' )
    decode
    esac

    elif [[ "$1" != "" ]]; then
    case $1 in
    '-g' | '--gen-pass' )
    generate "false"
    esac

    elif [[ "$1" == "-e" || "$1" == "--encode" ]]; then
    if [[ "$1" != "" && "$2" != "" ]]; then
    case $2 in
    '-g' | '--gen-pass' )
    generate "true"
    esac
    fi

    else
    clear
    echo -e "\n$RED[!] Unhandled Option$RESET"
    echo -e "\nThis script expects at least one valid CLI argument."
    echo -e "./script.sh --encode [-e]"
    echo -e "./script.sh --decode [-d]"
    echo -e "./script.sh --gen-pass [-g]\n"

    echo -e "To encode file with a randomly generated password"
    echo -e "please pass the following as command line options:\n"

    echo -e "./script.sh --encode [-e] --gen-pass [-g]\n"
    sleep 1 && exit 1
    fi



    I know, nothing ground breaking, but solid and reliable, and hey if you want some extra security the output gets base64, so you could hide these files among your genuine certs and such.
    The following users say it would be alright if the author of this post didn't die in a fire!
  2. #2
    Aleister Crowley African Astronaut
    Is that what you use for your CP and Una Bomber diaries yeah?
  3. #3
    aldra JIDF Controlled Opposition
    gpg -ae lol
  4. #4
    Sophie Pedophile Tech Support
    Originally posted by Aleister Crowley Is that what you use for your CP and Una Bomber diaries yeah?

    No for that i use dedicated hard drives which are fully encrypted with LUKS-2 or VeraCrypt.
  5. #5
    Sophie Pedophile Tech Support
    Originally posted by aldra gpg -ae lol

    OpenSSL is superior. You have 40+ encryption schemes. B64 is suitable for transport over HTTP/S. You can generate certs that you can use as keyfiles, etc, etc, etc. This script is minimalistic because AES256 -> B64 is what i use most often.
Jump to Top