From 63e3522f06c63cbbd3192ebe99c8d4bae3c859a0 Mon Sep 17 00:00:00 2001
From: Dalibor Pospisil <dapospis@redhat.com>
Date: Thu, 19 Jun 2014 12:00:45 +0200
Subject: [PATCH 04/14] rlHash: added base64_ algorithm, defaul algorithm
changed to hex
---
src/infrastructure.sh | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/infrastructure.sh b/src/infrastructure.sh
index 8c8d7c7..66643e3 100644
--- a/src/infrastructure.sh
+++ b/src/infrastructure.sh
@@ -353,9 +353,10 @@ Unhash given string.
Use given hash algorithm.
Currently supported algorithms:
base64
+ base64_ - this is standard base64 where '=' is replaced by '_'
hex
-Defaults to base64.
+Defaults to hex.
Default algorithm can be override using global variable rlHashAlgorithm.
=item --stdin
@@ -388,15 +389,22 @@ rlHash() {
esac
shift
done
- [[ "$alg" =~ ^(base64|hex)$ ]] || alg='base64'
+ [[ "$alg" =~ ^(base64|base64_|hex)$ ]] || alg='hex'
local text="$1" command
case $alg in
base64)
if [[ $decode -eq 0 ]]; then
- command="base64 --wrap 0 | tr '=' '.'"
+ command="base64 --wrap 0"
else
- command="tr '.' '=' | base64 --decode"
+ command="base64 --decode"
+ fi
+ ;;
+ base64_)
+ if [[ $decode -eq 0 ]]; then
+ command="base64 --wrap 0 | tr '=' '_'"
+ else
+ command="tr '_' '=' | base64 --decode"
fi
;;
hex)
--
1.9.3