$INCLUDE "rapidq.inc"
DECLARE SUB dclose
DECLARE SUB keysetup ()
DECLARE SUB rc4 ()
DIM k(0 TO 255)
DIM s(0 TO 255)
DIM filename AS STRING
DIM t$ AS STRING
DIM d$ AS STRING
DIM c$ AS STRING
DIM pw$ AS STRING
DIM w$ AS STRING
DIM ja$ AS STRING
DIM za$ AS STRING
DIM g AS INTEGER
DIM x AS INTEGER
DIM y AS INTEGER
DIM i AS INTEGER
DIM z AS INTEGER
DIM w AS INTEGER
DIM fxfont AS QFONT
fxfont.name="Arial"
fxfont.size=10
DIM mainform AS QFORM
mainform.CAPTION = "Securepad v2.0 "
mainform.Width = 700
mainform.Height = 400
mainform.Center
DIM richedit AS QRICHEDIT
richedit.PARENT=mainform
richedit.width=mainform.clientwidth
richedit.height=mainform.clientheight
richedit.scrollbars=2
richedit.align=5
richedit.plaintext=true
richedit.wordwrap=true
richedit.font=fxfont
DIM statusbar AS QSTATUSBAR
statusbar.height=20
statusbar.width=700
statusbar.top=400
statusbar.PARENT=mainform
DIM dialogbox AS QFORM
DIM editbox AS QEDIT
DIM button AS QBUTTON
dialogbox.borderstyle=bsdialog
dialogbox.CAPTION="Password.."
dialogbox.width=320
dialogbox.height=76
dialogbox.center
editbox.PARENT=dialogbox
editbox.top=13
editbox.left=3
editbox.width=257
editbox.text=""
editbox.passwordchar="*"
editbox.font=fxfont
button.PARENT=dialogbox
button.CAPTION="&OK"
button.top=13
button.left=272
button.width=27
button.height=28
button.onclick=dclose
DIM mainmenu AS QMAINMENU
mainmenu.PARENT=mainform
DIM file AS QMENUITEM
DIM edit AS QMENUITEM
DIM about AS QMENUITEM
DIM list AS QMENUITEM
DIM new AS QMENUITEM
DIM OPEN AS QMENUITEM
DIM save AS QMENUITEM
DIM saveas AS QMENUITEM
DIM encrypt AS QMENUITEM
DIM decrypt AS QMENUITEM
DIM prints AS QMENUITEM
DIM exits AS QMENUITEM
DIM selectall AS QMENUITEM
DIM copy AS QMENUITEM
DIM paste AS QMENUITEM
DIM cut AS QMENUITEM
DIM setfont AS QMENUITEM
DIM clip AS QMENUITEM
DIM popupmenu AS QPOPUPMENU
mainform.popupmenu=popupmenu
DIM cuts AS QMENUITEM
cuts.CAPTION="Cut"
DIM copys AS QMENUITEM
copys.CAPTION="Copy"
DIM pastes AS QMENUITEM
pastes.CAPTION="Paste"
DIM selectsall AS QMENUITEM
selectsall.CAPTION="Select all"
popupmenu.additems cuts,copys,pastes,selectsall
SUB newclick
richedit.clear
mainform.CAPTION="Securepad v2.0 "+" Untitled"
statusbar.simpletext=""
END SUB
SUB openclick
statusbar.simpletext=""
DIM opendialog AS QOPENDIALOG
opendialog.filter="text files (*.txt)|*.txt|all files (*.*)|*.*"
IF opendialog.EXECUTE THEN
filename=opendialog.filename
mainform.CAPTION="Securepad v2.0 "+" "+filename
richedit.loadfromfile filename
END IF
END SUB
SUB saveasclick
statusbar.simpletext=""
DIM savedialog AS QSAVEDIALOG
savedialog.filter="text files (*.txt)|*.txt|all files (*.*)|*.*"
IF savedialog.EXECUTE THEN
filename=savedialog.filename
mainform.CAPTION="Securepad v2.0 "+" "+filename
richedit.savetofile filename
END IF
END SUB
SUB exitsclick
mainform.CLOSE
END SUB
SUB saveclick
statusbar.simpletext=""
richedit.savetofile filename
END SUB
SUB copyclick
statusbar.simpletext=""
richedit.copytoclipboard
END SUB
SUB pasteclick
statusbar.simpletext=""
richedit.pastefromclipboard
END SUB
SUB cutclick
statusbar.simpletext=""
richedit.cuttoclipboard
END SUB
SUB printsclick
statusbar.simpletext=""
statusbar.simpletext="formatting text.please wait.."
t$=""
printer.font=fxfont
t$=richedit.text
c$=""
x=200:z=1:w=1
aa:
IF z>LEN(t$) THEN GOTO ww
d$=MID$(t$,z,1):x=x+printer.textwidth(d$)
c$=c$+d$
IF x>(printer.pagewidth-200) THEN GOSUB align:x=200:w=z
IF d$=CHR$(13) THEN x=200:w=z
IF d$=CHR$(10) THEN x=200:w=z
z=z+1
GOTO aa
align:
FOR l=z TO w+1 STEP-1
IF MID$(c$,l,1)=" " THEN c$=LEFT$(c$,l-1)+CHR$(13):z=l:d$="":RETURN
NEXT l
c$=LEFT$(c$,z-1)+CHR$(13)
z=z-1
d$=""
RETURN
ww:
statusbar.simpletext="now printing.."
x=200:y=200
printer.begindoc
FOR i=1 TO LEN(c$)
d$=MID$(c$,i,1)
IF d$=CHR$(13) THEN
d$=""
x=200:y=y+printer.textheight(c$)
IF y>(printer.pageheight-200) THEN
x=200:y=200:printer.newpage
END IF
END IF
IF d$=CHR$(10)THEN
d$=""
END IF
printer.textout(x,y,d$,printer.font,-1)
x=x+printer.textwidth(d$)
NEXT i
printer.enddoc
statusbar.simpletext=""
END SUB
SUB selectallclick
statusbar.simpletext=""
richedit.selectall
END SUB
SUB dclose
dialogbox.CLOSE
END SUB
SUB passwordclick
dialogbox.SHOWMODAL
END SUB
SUB keysetup
FOR i=0 TO 255
s(i)=i
NEXT i
j=1
FOR i=0 TO 255
IF j>LEN(pw$) THEN j=1
k(i)=ASC(MID$(pw$,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
END SUB
SUB rc4
i=0
j=0
FOR p=1 TO LEN(t$)
a=ASC(MID$(t$,p,1))
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
g=s(t)
c=a XOR g
w$=w$+CHR$(c)
NEXT p
END SUB
SUB encryptclick
w$="":ja$=:t$="":editbox.text=""
passwordclick
pw$=editbox.text
IF pw$="" THEN EXIT SUB
keysetup
t$=richedit.text
statusbar.simpletext="please wait..."
rc4
FOR ta=1 TO LEN(w$)
ta$=MID$(w$,ta,1)
za$=STR$(ASC(ta$))
IF LEN(za$)=1 THEN za$="00"+za$
IF LEN(za$)=2 THEN za$="0"+za$
IF LEN(za$)=3 THEN za$=za$
ja$=ja$+za$
NEXT ta
richedit.text=ja$
statusbar.simpletext="file encrypted"
END SUB
SUB decryptclick
w$="":ja$="":t$="":editbox.text=""
passwordclick
pw$=editbox.text
IF pw$="" THEN EXIT SUB
keysetup
ja$=richedit.text
statusbar.simpletext="please wait..."
FOR ta=1 TO LEN(ja$) STEP 3
ta$=MID$(ja$,ta,3)
za$=CHR$(VAL(ta$))
t$=t$+za$
NEXT ta
rc4
richedit.text=w$
statusbar.simpletext="file decrypted"
END SUB
SUB setfontclick
DIM fontdialog AS QFONTDIALOG
fontdialog.getfont(fxfont)
IF fontdialog.EXECUTE=true THEN
fontdialog.setfont(fxfont)
richedit.font=fxfont
END IF
END SUB
SUB clipclick
statusbar.simpletext=""
clipboard.clear
END SUB
file.CAPTION="&File"
edit.CAPTION="&Edit"
about.CAPTION="&About"
mainmenu.additems file,edit,about
new.CAPTION="&New"
OPEN.CAPTION="&Open"
save.CAPTION="&Save"
saveas.CAPTION="&Save as.."
encrypt.CAPTION="&Encrypt"
decrypt.CAPTION="&Decrypt"
prints.CAPTION="&Print"
exits.CAPTION="&Exit"
file.additems new,OPEN,save,saveas,encrypt,decrypt,prints,exits
list.CAPTION="&By S.Boukas (c)2006"
about.additems list
copy.CAPTION="&Copy"
paste.CAPTION="&Paste"
cut.CAPTION="&Cut"
selectall.CAPTION="&Select All"
setfont.CAPTION="&Set font"
clip.CAPTION="&Clear clipboard"
edit.additems copy,paste,cut,selectall,setfont,clip
new.onclick=newclick
OPEN.onclick=openclick
save.onclick=saveclick
saveas.onclick=saveasclick
exits.onclick=exitsclick
encrypt.onclick=encryptclick
decrypt.onclick=decryptclick
prints.onclick=printsclick
copy.onclick=copyclick
paste.onclick=pasteclick
cut.onclick=cutclick
selectall.onclick=selectallclick
setfont.onclick=setfontclick
clip.onclick=clipclick
cuts.onclick=cutclick
copys.onclick=copyclick
pastes.onclick=pasteclick
selectsall.onclick=selectallclick
MAINFORM.SHOWMODAL
|
|