Last active
August 29, 2015 13:59
-
-
Save mjf/10715695 to your computer and use it in GitHub Desktop.
encdec-tools - Ecrypt file and decript, typeset and search encrypted file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# dec - Decrypt encrypted file | |
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/> | |
# Released under the terms of The MIT License | |
ENC_CIPHALG="${ENC_CIPHALG:-aes-256-cbc}" | |
ENC_FILEEXT="${ENC_FILEEXT:-enc}" | |
if [ $# -ne 1 ] | |
then | |
echo 'Usage: dec FILE' 1>&2 | |
exit 1 | |
fi | |
file="$1" | |
deccat "$file" > "$file" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# deccat - Catenate encrypted file | |
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/> | |
# Released under the terms of The MIT License | |
ENC_CIPHALG="${ENC_CIPHALG:-aes-256-cbc}" | |
ENC_FILEEXT="${ENC_FILEEXT:-enc}" | |
if [ $# -ne 1 ] | |
then | |
echo 'Usage: deccat FILE' 1>&2 | |
exit 1 | |
fi | |
file="$1" | |
openssl "$ENC_CIPHALG" -d -a -salt -in ."$file.$ENC_FILEEXT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# decgrep - Search encrypted file | |
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/> | |
# Released under the terms of The MIT License | |
if [ $# -ne 2 ] | |
then | |
echo 'Usage: decgrep PATTERN FILE' 1>&2 | |
exit 1 | |
fi | |
pattern="$1" | |
file="$2" | |
deccat "$file" | grep -i "$pattern" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# end - Encrypt file | |
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/> | |
# Released under the terms of The MIT License | |
ENC_CIPHALG="${ENC_CIPHALG:-aes-256-cbc}" | |
ENC_FILEEXT="${ENC_FILEEXT:-enc}" | |
if [ $# -ne 1 ] | |
then | |
echo 'Usage: enc FILE' 1>&2 | |
exit 1 | |
fi | |
file="$1" | |
if openssl "$ENC_CIPHALG" -a -salt -in "$file" -out ."$file.$ENC_FILEEXT" | |
then | |
rm -i "$file" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment