Skip to content

Commit

Permalink
back to sed
Browse files Browse the repository at this point in the history
  • Loading branch information
andreineculau authored Aug 23, 2024
1 parent 0ee7a1b commit 4226ba8
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions transcrypt
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,6 @@ is_salt_prefix_workaround_required() {
fi
}

# source https://stackoverflow.com/a/42828523/465684
hex2string() {
local hex_input=""
local I=0
while read -r line; do hex_input+="$line"; done
while [ $I -lt ${#hex_input} ]; do
echo -en "\x${hex_input:$I:2}"
((I += 2))
done
}

# The `decryption -> encryption` process on an unchanged file must be
# deterministic for everything to work transparently. To do that, the same
# salt must be used each time we encrypt the same file. An HMAC has been
Expand Down Expand Up @@ -227,7 +216,7 @@ git_clean() {
if [ "$(is_salt_prefix_workaround_required)" == "true" ]; then
# Encrypt the file to base64, ensuring it includes the prefix 'Salted__' with the salt. #133
(
echo -n "Salted__" && echo -n "$salt" | hex2string &&
echo -n "Salted__" && echo -n "$salt" | sed "s/../\\\\x&/g" | xargs -0 printf "%b" &&
# Encrypt file to binary ciphertext
ENC_PASS=$password "$openssl_path" enc -e "-${cipher}" -md MD5 -pass env:ENC_PASS -S "$salt" -in "$tempfile"
) |
Expand Down

0 comments on commit 4226ba8

Please sign in to comment.