Input
Anmeldungsdatum: 28.07.2014 Beiträge: 59
|
Verfasst am: 30.06.2015, 11:23 Titel: |
|
|
So, hab's mal noch etwas verbessert:
Code: |
#include once "windows.bi"
#include once "win\commdlg.bi"
declare function loadsavedialog(_
savedlog as integer=0,_
filter as string="txt",_
fltrindex as integer=4,_
initdir as string="c:\Desktop",_
strDefExt as string="txt") as string
dim as integer i,j,m,n
dim as string datei1,datei2,feld,fil,modus,pw,zeichen
fil="DOC Dateien (*.DOC)"+chr(0)+"*.doc"+chr(0)_
+"EXE Dateien (*.EXE)"+chr(0)+"*.exe"+chr(0)_
+"PDF Dateien (*.PDF)"+chr(0)+"*.pdf"+chr(0)_
+"TXT Dateien (*.TXT)"+chr(0)+"*.txt"+chr(0)_
+"Alle Dateien (*.*)"+chr(0)+"*.*"+chr(0,0)
do
input "Passwort:",pw
loop until pw<>""
for i=0 to len(pw)-1
m+=pw[i]
next
m=fix(sqr(m))
datei1=LoadSaveDialog(0,fil,5,"c:\Desktop","txt")
if datei1="" then
datei1="Text.txt"
shell "start notepad Text.txt"
end if
print "1=Encoder 2=Decoder"
sleep
modus=inkey
if modus="1" then
locate 3
print "Modus: Encoder",""
end if
if modus="2" then
locate 3
print "Modus: Decoder",""
end if
print "Einlesen ..."
open datei1 for binary access read as #1
zeichen=input(lof(1),#1)
close
n=bitreset(len(zeichen),0)
feld=zeichen
print ""
if modus="1" then
for j=0 to m
for i=0 to n/2-1
feld[n/2+i]=zeichen[i*2]
feld[i]=zeichen[i*2+1]
next
zeichen=feld
locate csrlin-1,0
print "Fortschritt:";fix(100*j/m);"%"
next
j=0
for i=0 to len(zeichen)-1
zeichen[i]=zeichen[i] xor (i mod pw[j])
j=iif(j>=len(pw)-1,0,j+1)
next
end if
if modus="2" then
j=0
for i=0 to len(zeichen)-1
zeichen[i]=zeichen[i] xor (i mod pw[j])
j=iif(j>=len(pw)-1,0,j+1)
next
feld=zeichen
for j=0 to m
for i=0 to n/2-1
feld[i*2]=zeichen[n/2+i]
feld[i*2+1]=zeichen[i]
next
zeichen=feld
locate csrlin-1,0
print "Fortschritt:";fix(100*j/m);"%"
next
end if
print "Schreiben ..."
datei2=LoadSaveDialog(1,fil,5,"c:\Desktop","txt")
if datei2="" then datei2="Text.txt"
open datei2 for output as #1
print #1,zeichen;
close
end
function loadsavedialog(savedlog as integer,_
filter as string,fltrindex as integer,_
initdir as string,strdefext as string) as string
dim fb_ofn as openfilename
fb_ofn.lstructsize=len(fb_ofn)
fb_ofn.hwndowner=0
fb_ofn.hinstance=0
dim strfilter as string
if filter="" then
strfilter="Alle Dateien (*.*)"+chr(0)+"*.*"+chr(0,0)
else
strfilter=filter+chr(0,0)
end if
fb_ofn.lpstrfilter=strptr(strfilter)
fb_ofn.nfilterindex=fltrindex
dim strfile as string*2048
strfile = space(2047)+chr(0)
fb_ofn.lpstrfile=strptr(strfile)
fb_ofn.nmaxfile=len(strfile)
dim strfiletitle as string*2048
strfiletitle=string(2048,0)
fb_ofn.lpstrfiletitle=strptr(strfiletitle)
fb_ofn.nmaxfiletitle=len(strfiletitle)
dim strdrstr as string
if initdir="" then
strdrstr="."
else
strdrstr=initdir
end if
fb_ofn.lpstrinitialdir=strptr(strdrstr)
dim strcapt as string
if savedlog then
strcapt="Dateien speichern"
fb_ofn.lpstrtitle=strptr(strcapt)
if strdefext>"" then
dim strdext as string
strdext=strdefext
fb_ofn.lpstrdefext=strptr(strdext)
end if
fb_ofn.flags=ofn_explorer or ofn_longnames or ofn_overwriteprompt or ofn_hidereadonly
if getsavefilename(@fb_ofn) then loadsavedialog=trim(strfile)
else
strcapt="Dateien öffnen"
fb_ofn.lpstrtitle=strptr(strcapt)
fb_ofn.flags=ofn_explorer or ofn_longnames or ofn_createprompt or _
ofn_nodereferencelinks or ofn_hidereadonly
if getopenfilename(@fb_ofn) then loadsavedialog=trim(strfile)
end if
end function
|
|
|