home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1991-11-16 | 2.5 KB | 109 lines |
- Rem *******************
- Rem ** vignere table **
- Rem ** by s.bradley **
- Rem *******************
- Hide : Colour 1,$FF0
- Rem ******************
- Rem ***set up table***
- Rem ******************
- Dim VN$(27,27) : C=1
- Global VN$(),C$,PW$,FL
- For I=2 To 27
- VN$(1,I)=Chr$(63+I)
- VN$(I,1)=Chr$(63+I)
- Next I
- For I=2 To 27
- For F=2 To 27
- VN$(I,F)=Chr$(64+C)
- Inc C : If C>26 Then C=1
- Next F : Inc C : Next I
- VN$(1,1)=Chr$(32)
- Rem *******************
- Rem ***title screen ***
- Rem *******************
- TITLE:
- Set Rainbow 0,0,100,"(9,2,9)","(9,2,9)",""
- Rainbow 0,1,50,80
- Curs Off : Paper(0) : Pen(2) : Cls
- Print : Centre "vignere table" : Print
- Centre "by" : Print
- Centre "s.bradley"
- Print : Print : Pen(6)
- Print " 1 - encipher message"
- Print " 2 - decipher code"
- Print " 3 - end program"
- Do
- IP$=Inkey$
- If IP$="1" Then Proc ENCIPHER : Goto TITLE :
- If IP$="2" Then Proc DEIPHER : Goto TITLE :
- If IP$="3" Then Edit
- Loop
- Rem ************************
- Rem *** check for errors ***
- Rem ************************
- Procedure ERR
- FL=0
- If PW$="" Then FL=1 : Pop Proc
- If C$="" Then FL=1 : Pop Proc
- For I=1 To Len(PW$)
- D=Asc(Mid$(PW$,I,1))
- If D<65 or D>90 Then Pen(3) : Print "bad password" : FL=1 : I=Len(PW$)
- Next I
- For I=1 To Len(C$)
- D=Asc(Mid$(C$,I,1))
- If D=32 Then Goto JMP :
- If D<65 or D>90 Then Pen(3) : Print "bad input" : FL=1 : I=Len(C$) :
- JMP:
- Next I
- End Proc
- Rem ********************
- Rem *** code message ***
- Rem ********************
- Procedure ENCIPHER
- BEGIN:
- Locate 0,10 : Pen(7) : Cls ,0,71 To 320,200
- Input "enter password ";PW$
- Input "enter message ";C$
- Curs Off
- PW$=Upper$(PW$)
- C$=Upper$(C$)
- Proc ERR
- If FL=1 Then Bell : Wait 100 : Goto BEGIN :
- Print : Print
- For I=1 To Len(C$)
- R=Asc(Mid$(C$,I,1))-64
- Inc PC : If PC>Len(PW$) Then PC=1
- If R=-32 Then R=0 : B=0 : Goto PRINEN :
- B=Asc(Mid$(PW$,PC,1))-64
- PRINEN:
- Pen(1) : Print VN$(B+1,R+1); : Play 1,R+20,2
- Next I
- Pen(3) : Print : Print : Print "press a key to return"
- Wait Key : Bell 80
- End Proc
- Rem ******************
- Rem *** crack code ***
- Rem ******************
- Procedure DEIPHER
- BEGIN:
- Locate 0,10 : Pen(7) : Cls ,0,71 To 320,200
- Input "enter password ";PW$
- Input "enter code ";C$
- Curs Off
- PW$=Upper$(PW$)
- C$=Upper$(C$)
- Proc ERR
- If FL=1 Then Bell : Wait 100 : Goto BEGIN :
- Print : Print
- For G=1 To Len(C$)
- Inc PC : If PC>Len(PW$) Then PC=1
- H=Asc(Mid$(PW$,PC,1))-64
- T=Asc(Mid$(C$,G,1))-64
- If T=-32 Then Print " ";
- For Z=2 To 27
- A=Asc(VN$(H+1,Z))-64
- If T=A Then Pen(1) : Print VN$(1,Z); : Play 1,H+30,2
- Next Z : Next G
- Pen(3) : Print : Print : Print "press a key to return"
- Wait Key : Bell 80
- End Proc