Advertisement
IsraelTorres

conversion

Sep 20th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.43 KB | None | 0 0
  1. #!/bin/bash
  2. # Israel Torres
  3. # 20160920
  4. #
  5. STRING='Here I am, and there you are.'
  6.  
  7. function chr () { # in 65, out A
  8. [ "$1" -lt 256 ] || return 1
  9. printf "\\$(printf '%03o' "$1")"
  10. }
  11.  
  12. function ord () { # in A, out 65
  13. LC_CTYPE=C printf '%d' "'$1"
  14. }
  15.  
  16. for (( c=0; c<=${#STRING}; c++ )); do
  17. #echo -en "${STRING:$c:1}"
  18. ORDVAR=$(ord "${STRING:$c:1}")
  19. XORVAR=$(( ORDVAR ^ 20 ))
  20. #echo -en "$XORVAR"
  21. CHRVAR=$(chr $XORVAR)
  22. echo -en "$CHRVAR"
  23. done
  24.  
  25. #EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement