Does EB have an encryption routine? I haven't been able to find one.
I wrote one, which I brought over from QB45. Doesn't work well. Here it is:
sub encrypt
filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt||"
filenames = filerequest("Select File",0,1,filter,"txt",@MULTISELECT, "*.txt")
do
pos = instr(filenames,"|")
if(pos)
filetemp = left$(filenames,pos-1)
filenames = mid$(filenames,pos+1)
PassWord$ = "â€Ã...¡ â€Ã,¦ ÂÃ,¹ ÂÃ,³ÃÆ'Ã,º,ÂÃ,©Ã‚Ã,¤ d/o?g}f[i)g+hÃÆ'Ã...“t"
LenOfKey = LEN(PassWord$)
InCharByte$ = SPACE$(1)
Keylocation = 1
TempFile$ = "FileDump.Txt"
IF(OPENFILE(myfile,"*.Txt","R") = 0)
if(READ(myfile,ln) = 0)
if LEFT$(ln, 9) = "Encrypted" THEN
Encry = 1
endif
closefile myfile
endif
IF(OPENFILE(myfile,"*.Txt","W") = 0)
IF Encry = 0
WRITE myfile,"Encrypted File. Any attempts to unlock will destroy the file."
CLOSEFILE myfile
endif
endif
IF(OPENFILE(myfile,"*.Txt","R") = 0)
if Encry = 1
IF(READ(myfile,ln) = 0)
ComeOnLn = 1
ENDIF
endif
endif
DO
if EOF(myfile)
exit do
endif
if(READ(myfile,ln) = 0)
FOR CheckLine = 1 TO LEN(ln)
InCharByte$ = MID$(ln, CheckLine, 1)
IF InCharByte$ = "" THEN InCharByte$ = "%"
IF Encry = 1 THEN
AltAsc = ASC(InCharByte$) - ASC(MID$(PassWord$, Keylocation, 1))
ELSEIF Encry = 0 THEN
AltAsc = ASC(InCharByte$) + ASC(MID$(PassWord$, Keylocation, 1))
ENDIF
Keylocation = Keylocation + 1
IF Encry = 1 THEN
IF AltAsc < 1 THEN AltAsc = 223 + AltAsc
ELSEIF Encry = 0 THEN
IF AltAsc > 254 THEN AltAsc = AltAsc - 223
ENDIF
IF Keylocation > LenOfKey
Keylocation = 1
PlaceMe$ = PlaceMe$ + CHR$(AltAsc)
ENDIF
NEXT CheckLine
Write PRINT PlaceMe$
PlaceMe$ = ""
UNTIL EOF(myfile)
endif
until pos = 0
RETURN
Hi
There is a small box at the top of the forum that is labeled Search if before you had posted typed in the word "encryption" you would have found that the topic has been covered before !!!
there is a RC4 routine posted here http://www.ionicwind.com/forums/index.php/topic,2424.0.html :-)
That's cool, its got to be the first time anything I "wrote" has ever been re-posted by someone else.
Anyways, after I originally ported that RC4 routine from.. I think VB, it came to my attention that while the algorithm it self can be used by anyone freely, you need to becareful what you call it. The accepted name is apparently ArcFour - so I changed the name in a newer incarnation. Also, the size of the string is now dynamic in the last version. So this should be a little more useful.
'$Define DLL
$IfNDef DLL
Print ArcFour(ArcFour("BLAH","BLAH"),"BLAH")
Print ArcFour("BLAH","BLAH")
Print ArcFour("24z0","24g3"),"\t| Should be nhnW"
Print ArcFour("24z2","24g3"),"\t| Should be nhnU"
Print ArcFour("5ybu8","5ybdt"),"\t| Should be XJrkp"
Do:Until Inkey$<>""
$EndIf
$IfDef DLL
Export ArcFour
$EndIf
Sub ArcFour(inp As String,key As String),Heap
Dim S[256],K[256],temp,y As Char
Dim i,j,t,x As Int
Dim Outp As Pointer
Outp=AllocHeap(Len(inp)+1)
For i=0 to 255
S[i]=i
Next i
j=1
For i=0 to 255
If j>Len(key) Then j=1
K[i]=Asc(Mid$(key,j,1))
j++
Next i
j=0
For i=0 to 255
j=(j+S[i]+K[i])%256
temp=S[i]
S[i]=S[j]
S[j]=temp
Next i
i=0
j=0
For x=1 to Len(inp)
i=(i+1)%256
j=(j+S[i])%256
temp=S[i]
S[i]=S[j]
S[j]=temp
t=(S[i]+(S[j]%256))%256
Y=S[t]
#<String>Outp+=Chr$(Asc(Mid$(inp,x,1))||Y)
Next x
Return #<String>Outp
EndSub
I suggest anyone using ArcFour encryption read up on its weaknesses. This is the best encryption available in EB at this time, but its only because noone who is better than me has taken a crack at it yet.
http://en.wikipedia.org/wiki/RC4
Thanx for all the input. I like WayneA's encryption routine. I'm going to try it out.
I did do a "search" but typed in "encrypt" instead of "encryption". This time I used
"encryption" and got some good responses.
Regards, Don Smith [AKA MarineDon]