mvadkert / rpms / beakerlib

Forked from rpms/beakerlib 6 years ago
Clone

Blame 0004-rlHash-added-base64_-algorithm-defaul-algorithm-chan.patch

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