How to encrypt a file using Bash?
up vote
-2
down vote
favorite
I am trying to encrypt a test file I have and decrypt the file using a bash script.
I searched online and found I can use openssl and salt
to do this.
I found the following code online:
FNAME=$1
if [[ -z "$FNAME" ]]; then
echo "cryptde <name of file>"
echo " - cryptde is a script to decrypt des3 encrypted files"
exit;
fi
openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
How does it work?
bash encryption
add a comment |
up vote
-2
down vote
favorite
I am trying to encrypt a test file I have and decrypt the file using a bash script.
I searched online and found I can use openssl and salt
to do this.
I found the following code online:
FNAME=$1
if [[ -z "$FNAME" ]]; then
echo "cryptde <name of file>"
echo " - cryptde is a script to decrypt des3 encrypted files"
exit;
fi
openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
How does it work?
bash encryption
What part do you not understand? Read the man page for each command.
– user1133275
Oct 11 '17 at 18:56
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I am trying to encrypt a test file I have and decrypt the file using a bash script.
I searched online and found I can use openssl and salt
to do this.
I found the following code online:
FNAME=$1
if [[ -z "$FNAME" ]]; then
echo "cryptde <name of file>"
echo " - cryptde is a script to decrypt des3 encrypted files"
exit;
fi
openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
How does it work?
bash encryption
I am trying to encrypt a test file I have and decrypt the file using a bash script.
I searched online and found I can use openssl and salt
to do this.
I found the following code online:
FNAME=$1
if [[ -z "$FNAME" ]]; then
echo "cryptde <name of file>"
echo " - cryptde is a script to decrypt des3 encrypted files"
exit;
fi
openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
How does it work?
bash encryption
bash encryption
edited Nov 25 at 14:18
Rui F Ribeiro
38.3k1475126
38.3k1475126
asked Oct 11 '17 at 17:48
Allen
11
11
What part do you not understand? Read the man page for each command.
– user1133275
Oct 11 '17 at 18:56
add a comment |
What part do you not understand? Read the man page for each command.
– user1133275
Oct 11 '17 at 18:56
What part do you not understand? Read the man page for each command.
– user1133275
Oct 11 '17 at 18:56
What part do you not understand? Read the man page for each command.
– user1133275
Oct 11 '17 at 18:56
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
- FNAME=$1
This assigns the first parameter to FNAME
- if [[ -z "$FNAME" ]]; then
If the string $FNAME is zero in length, then echo the help output and exit
- openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
This line runs the openssl command's des3 module (man des3) takes $FNAME as input file name, then writes output to $FNAME without a .extension. This final argument is a regular expression that strips the extension off (.[NOT .]any number of times.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
- FNAME=$1
This assigns the first parameter to FNAME
- if [[ -z "$FNAME" ]]; then
If the string $FNAME is zero in length, then echo the help output and exit
- openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
This line runs the openssl command's des3 module (man des3) takes $FNAME as input file name, then writes output to $FNAME without a .extension. This final argument is a regular expression that strips the extension off (.[NOT .]any number of times.
add a comment |
up vote
0
down vote
accepted
- FNAME=$1
This assigns the first parameter to FNAME
- if [[ -z "$FNAME" ]]; then
If the string $FNAME is zero in length, then echo the help output and exit
- openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
This line runs the openssl command's des3 module (man des3) takes $FNAME as input file name, then writes output to $FNAME without a .extension. This final argument is a regular expression that strips the extension off (.[NOT .]any number of times.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
- FNAME=$1
This assigns the first parameter to FNAME
- if [[ -z "$FNAME" ]]; then
If the string $FNAME is zero in length, then echo the help output and exit
- openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
This line runs the openssl command's des3 module (man des3) takes $FNAME as input file name, then writes output to $FNAME without a .extension. This final argument is a regular expression that strips the extension off (.[NOT .]any number of times.
- FNAME=$1
This assigns the first parameter to FNAME
- if [[ -z "$FNAME" ]]; then
If the string $FNAME is zero in length, then echo the help output and exit
- openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
This line runs the openssl command's des3 module (man des3) takes $FNAME as input file name, then writes output to $FNAME without a .extension. This final argument is a regular expression that strips the extension off (.[NOT .]any number of times.
answered Oct 11 '17 at 18:56
Ed Neville
1,13157
1,13157
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397537%2fhow-to-encrypt-a-file-using-bash%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What part do you not understand? Read the man page for each command.
– user1133275
Oct 11 '17 at 18:56