File: ask_for_key

package info (click to toggle)
afbackup 3.1beta1-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,500 kB
  • ctags: 1,685
  • sloc: ansic: 22,406; csh: 3,597; tcl: 964; sh: 403; makefile: 200
file content (22 lines) | stat: -rwxr-xr-x 655 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /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