Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:58:46+00:00 2026-06-10T18:58:46+00:00

I’m trying to create a scripted method for encrypting files, i’m trying to get

  • 0

I’m trying to create a scripted method for encrypting files, i’m trying to get this to perform the following actions:

Do a MD5 checksum against the file we’re encrypting, strip just the MD5 value and put it into a variable,

Ask the user for a password, (Wish I could use the openssl input method for password instead of having to use input from bash, seems less secure if it’s printing out to the terminal) but I’m not sure how to go about this, is there a valid secure way of doing this?

Anyhow, take that password, add in a # then the md5 sum after, IE: passhere#md5sumoforiginalfile

In a perfect world, it would tar.gz the file first and perform the encryption against the compressed archive.

This is where i’m sort of stumped, I’m having issues printing the md5 and incorporating the md5 hash into the password, also don’t feel right doing the input the way it is, is there a better way of doing this?

Thanks in advance all!

Here’s the function (originally grabbed from another script off the web by author: Matt Reid)

function encrypt() {
filein="$1"
fileout="$2"

if [ "$filein" = "no" ]; then
    echo -n "No input file specified, what file are we encrypting: "
    read filein
fi

if [ -r "$filein" ]; then
    if [ "$fileout" = "no" ]; then
        fileout="$filein.aes256"
    fi
    if [ -f "$fileout" ]; then
        echo "Output file exists already, encrypting will overwrite this file."
        echo -n "Do you want to encrypt anyway? [Y/n]: "
        read choice
        if [ "$choice" = "Y" ] || [ "$choice" = "y" ] || [ "$choice" = "" ]; then
    openssl enc -aes-256-cbc -a -salt -in $filein -out $fileout
            generate_digests $filein $fileout
            sdelete $filein
            exit 0;
        else 
            exit 2;
        fi      
    else
    filemd5=$(openssl dgst -md5 $filein | cut -d '  ' -f 1)
    echo "Please enter password: "
        read passvar
    openssl enc -aes-256-cbc -a -salt -out $fileout -k ${passvar}#${filemd5}
        generate_digests $filein $fileout
        sdelete $filein
        exit 0;
    fi
else
    echo "Input file does not exist or is not readable. You're attempting to encrypt file: '$filein'"
    exit 1;
fi
}

EDIT: Ok, I was able to get this working (minus the tar portion), but my question remains, is there a way to change this so I can use the hidden input from openssl enc for the password and some how modify the entered password by appending the #md5sumhere ? Not quite sure how to go about that.

Thanks again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:58:47+00:00Added an answer on June 10, 2026 at 6:58 pm

    I’d use a hashed password instead of a plaintext one:

    salt="astringtobeusedassalt"
    hashedpassword=`openssl passwd -salt $salt`
    echo $hashedpassword
    finalpassword="$hashedpassword""#""$filemd5" # $filemd5 variable from your script
    

    As a side note: please use sha1 or above when computing digests (sha256 is even more desirable)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.