]> git.ipfire.org Git - thirdparty/dehydrated.git/commitdiff
removed perl dependency
authorLukas Schauer <lukas@schauer.so>
Sat, 5 Dec 2015 21:06:36 +0000 (22:06 +0100)
committerLukas Schauer <lukas@schauer.so>
Sat, 5 Dec 2015 21:06:36 +0000 (22:06 +0100)
letsencrypt.sh

index 9c9662b095ee3e77c577950281d2d3211d1c997c..335803502eb60ec6797d05eb49041fe9072e7c4b 100755 (executable)
@@ -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() {