Computer

xor.sh

Bash script to xor a file with one char key.

#!/bin/bash
if·[·"$1"·=·""·]·||·[·"$2"·=·""·];·then
   echo·"Usage:·$0·<file>·<key>"
   exit
fi
key=$(printf·'%d'·"'$2")
while·read·-r·-s·-N·1·c;·do
   c=$(printf·'%d'·"'$c")
   if·[·"$c"·!=·"$key"·];·then
   »   c=$((c·^·key))
   fi 
   printf·"\\$(printf·'%o'·"$c")"
done·<·$1
USE IT AT YOUR OWN RISK!
Kudos: 0 [Give a kudo]

12r6j5xasef5Z6Sm4A6oBpMLn2ESPPX6ym
Ads: