$APPTYPE GUI
$INCLUDE "rapidq.inc"
DECLARE SUB CoolBtn1Click (Sender AS QCOOLBTN)
DECLARE SUB Button1Click (Sender AS QBUTTON)
DIM filename AS STRING
DIM f$ AS STRING
DIM b AS BYTE
DIM opendialog AS QOPENDIALOG
DIM file1 AS QFILESTREAM
DIM file2 AS QMEMORYSTREAM
CREATE Form AS QFORM
CAPTION = "Padlock v1.0..."
Width = 271
Height = 139
Center
CREATE CoolBtn1 AS QCOOLBTN
CAPTION = "..."
Left = 230
Top = 15
Width = 23
Height = 22
onclick=coolbtn1click
END CREATE
CREATE Edit1 AS QEDIT
Text = "Keyphrase"
Left = 11
Top = 15
Width = 217
END CREATE
CREATE ListBox1 AS QLISTBOX
Left = 11
Top = 44
Width = 217
Height = 21
TabOrder = 1
END CREATE
CREATE Button1 AS QBUTTON
CAPTION = "Crypt"
Left = 179
Top = 77
Width = 51
TabOrder = 2
onclick=button1click
END CREATE
END CREATE
DIM s(0 TO 255)
DIM k(0 TO 255)
Form.SHOWMODAL
SUB CoolBtn1Click (Sender AS QCOOLBTN)
listbox1.clear
IF opendialog.EXECUTE THEN
f$=opendialog.filename
listbox1.additems f$
END IF
END SUB
SUB Button1Click (Sender AS QBUTTON)
IF f$="" THEN SHOWMESSAGE("Please select file !")
k$=edit1.text
IF k$="" THEN SHOWMESSAGE("Please select a keyphrase !")
GOSUB keygen
file1.OPEN(f$,fmopenread)
i=0
j=0
aa:
IF file1.eof=-1 THEN file1.CLOSE:GOTO cc
file1.READ(b)
i=(i+1)MOD 256
j=(j+s(i))MOD 256
SWAP s(i),s(j)
t=(s(i)+(s(j)MOD 256))MOD 256
y=s(t)
c=y XOR b
c$=CHR$(c)
file2.write(c$)
GOTO aa
cc:
file1.OPEN(f$,fmcreate)
file1.copyfrom(file2,0)
file1.CLOSE
file2.CLOSE
SHOWMESSAGE("file processed !"):GOTO dd:
keygen:
FOR i=0 TO 255
s(i)=i
NEXT i
j=1
FOR i=0 TO 255
IF j>LEN(k$) THEN j=1
k(i)=ASC(MID$(k$,j,1))
j=j+1
NEXT i
j=0
FOR i=0 TO 255
j=(j+s(i)+k(i))MOD 256
SWAP s(i),s(j)
NEXT i
RETURN
dd:
END SUB
|