From 20e7d9d7a7b73be457dc029027ac252943820bdd Mon Sep 17 00:00:00 2001 From: Lukas Schauer Date: Sat, 5 Dec 2015 22:06:36 +0100 Subject: [PATCH] removed perl dependency --- letsencrypt.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/letsencrypt.sh b/letsencrypt.sh index 9c9662b..3358035 100755 --- a/letsencrypt.sh +++ b/letsencrypt.sh @@ -14,7 +14,24 @@ urlbase64() { } hex2bin() { - perl -pe 's/([0-9a-f]{2})/chr hex $1/gie' + tmphex="$(cat)" + + # remove spaces + hex='' + for ((i=0; i<${#tmphex}; i+=1)); do + test "${tmphex:$i:1}" == " " || hex="${hex}${tmphex:$i:1}" + done + + # add leading zero + test $((${#hex} & 1)) == 0 || hex="0${hex}" + + # convert to escaped string + escapedhex='' + for ((i=0; i<${#hex}; i+=2)); do + escapedhex=$escapedhex\\x${hex:$i:2} + done + + printf "${escapedhex}" } _request() { -- 2.47.2