File tree 1 file changed +14
-10
lines changed 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -139,16 +139,20 @@ git_clean() {
139
139
password=$( git config --get --local transcrypt.password)
140
140
openssl_path=$( git config --get --local transcrypt.openssl-path)
141
141
salt=$( " ${openssl_path} " dgst -hmac " ${filename} :${password} " -sha256 " $tempfile " | tr -d ' \r\n' | tail -c16)
142
- # Encrypt the file to base64, ensuring it always includes the prefix 'Salted__' with the salt. #133
143
- (
144
- # Always prepend encrypted ciphertext with "Salted__" prefix and binary salt value
145
- echo -n " Salted__" && echo -n " $salt " | xxd -r -p &&
146
- # Encrypt file to binary ciphertext
147
- ENC_PASS=$password " $openssl_path " enc -e " -${cipher} " -md MD5 -pass env:ENC_PASS -S " $salt " -in " $tempfile " |
148
- # Strip "Salted__" prefix and salt value if also added by OpenSSL (version < 3)
149
- LC_ALL=C sed -e " s/^\(Salted__.\{8\}\)\(.*\)/\2/"
150
- ) |
151
- base64
142
+
143
+ openssl_major_version=$( $openssl_path version | cut -d' ' -f2 | cut -d' .' -f1)
144
+ if [ " $openssl_major_version " -ge " 3" ]; then
145
+ # Encrypt the file to base64, ensuring it includes the prefix 'Salted__' with the salt. #133
146
+ (
147
+ echo -n " Salted__" && echo -n " $salt " | xxd -r -p &&
148
+ # Encrypt file to binary ciphertext
149
+ ENC_PASS=$password " $openssl_path " enc -e " -${cipher} " -md MD5 -pass env:ENC_PASS -S " $salt " -in " $tempfile "
150
+ ) |
151
+ base64
152
+ else
153
+ # Encrypt file to base64 ciphertext
154
+ ENC_PASS=$password " $openssl_path " enc -e -a " -${cipher} " -md MD5 -pass env:ENC_PASS -S " $salt " -in " $tempfile "
155
+ fi
152
156
fi
153
157
}
154
158
You can’t perform that action at this time.
0 commit comments