#! /bin/csh -f

echo "Please enter at least 5 characters as a unique"
echo "key for some encryption used for authenticating"
echo "the client to the server."
keyenter:
echo " "
echo -n "Key: "
set k="$<"
if (`echo "$k"|wc -c` < 5) then
  echo " "
  echo "Please enter AT LEAST FIVE characters."
  goto keyenter
endif

set h=`echo "$k" | od -b | head -1 | awk '{ s=0; for(i=0;i<=4;i++){ b=0; for(j=1;j<=3;j++){ b=(b*8)+substr($(i+2),j,1)} s=((s*95)+b-32)%2147483647} printf "%x\n",s}'`

\rm -f cryptkey.h
echo "#define	ACCESSKEY	0x$h" >! cryptkey.h

set k=`echo "$k"|sed 's#\\#\\\\\\\\#g;s#"#\\"#g'`
echo "#define	ACCESSKEYSTRING	"'"'"$k"'"' >> cryptkey.h
