Code Sample |
#!/bin/bash # # asci2hexkey.sh # Coverts ascii key to hex on the fly ASCIKEY="" echo "Type in ascii wifi key:" while read -s -n 1 ASCHAR; do [ "$ASCHAR" = "" ] && break printf "%X" $(printf "%d" \'"$ASCHAR"\') ASCIKEY=${ASCIKEY}${ASCHAR} done echo " = ascii key \"$ASCIKEY\"" |
Code Sample |
#!/usr/bin/perl # # asci2hexkey.pl # Takes asci key as command line argument & prints hex # use strict; use warnings; my $asciichars = shift; chomp $asciichars; my $hexchars = ''; foreach my $c (split(//,$asciichars)) { $hexchars .= sprintf "%x", ord($c); } print "$hexchars\n"; |
Code Sample |
#!/bin/bash # # asci2hexkey2.sh # Accepts an ascii key and outputs the hex equivalent, delimited by colons if [ $# -ne 1 ]; then exit 1 fi FIRST=1 IFS="" printf $1 | while read -s -n 1 ASCHAR; do if [ $FIRST -eq 0 ]; then printf ":" else FIRST=0 fi [ "$ASCHAR" = "" ] && break printf "%X" $(printf "%d" \'"$ASCHAR"\') done echo |
Quote |
Perhaps some kind of integration of this could be used in iwconfig? |
Quote |
include a reverse function |