Post by xcoder on Oct 13, 2023 9:08:20 GMT
print "Real RC4 File Encryption Base 85 Text"
''Real RC4 File Encryption Base 85 Text
'' Use Hexidecimal Key
global key$, key2$
BackgroundColor$ = "darkcyan"
ForegroundColor$ = "black"
WindowWidth = 300 : WindowHeight = 300
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.enc, "Encrypt", [encrypt], ul, 55, 155, 110, 25
button #main.dec, "Decrypt", [decrypt], ul, 55, 195, 110, 25
button #main.clearKey , "Clear Key", [clearKey], ul, 30, 75, 70, 20
textbox #main.key, 30, 45, 150, 20
statictext #main.encKey, "Encryption Key ", 20, 30, 170, 15
Open "Hex Key Selection " for window as #main
#main "trapclose [quit]"
key$ = "9e3779b9"
#main.key key$
wait
[encrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
close #main
call hexKey$
call readWriteFile
wait
[decrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
close #main
call hexKey$
call readWriteNext
wait
[advise]
notice "A Hex Key is required"
close #main
wait
[clearKey]
#main.key ""
wait
[quit]
close #main
End
sub hexKey$
for i = 1 to len(key$)step 2
chunk$ = mid$(key$,i,2)
byte = hexDec(chunk$)
key2$ = key2$ + chr$(byte)
print chunk$, byte
next i
print:print
print key2$
end sub
sub KSA '''key expansion
dim S(256)
dim K(256)
i = 0: j = 0
for i = 0 to 255
S(i)= i
next i
for i = 0 to 255
K(i)= asc(mid$(key2$,i mod len(key2$)+1))
next i
for i = 0 to 255
j = (j+ S(i)+ K(i))mod 256
temp = S(i)
S(i)= S(j)
S(j)= temp
next i
end sub
sub delay
timer 2000, [timertest]
wait
[timertest]
timer 0
end sub
sub readWriteFile
call KSA
call delay
filedialog "Open text file", "*.txt", infile$
print "File chosen is ";infile$
filedialog "Save As...", "*.txt", outfile$
print "File chosen is ";outfile$
open infile$ for input as #r
open outfile$ for output as #w
text$ = input$(#r, lof(#r))
alpha$ = txPRGA$(text$)
print #w, alpha$;
close #r
close #w
for i = 0 to 7
print space$(i);"Encrypting"
next i
print ""
print "Process Completed"
end sub
function txPRGA$(inString$) '''psuedo random byte generator
i = 0: j = 0
for x = 1 to len(inString$)
i = (i + 1) mod 256 '*********
byte = asc(mid$(inString$,x,1))
j = (j + S(i))mod 256
temp = S(i)
S(i) = S(j)
S(j) = temp
t = (S(i) + S(j))mod 256 '''changed real RC4
k = S(t) ''' changed real RC4
ck = byte xor k ''' changed real RC4
char$ = char$ + chr$(ck) ''' changed real RC4
next x
txPRGA$ = Format85$(char$)
end function
function Format85$(dat$)
Z85$ = "0123456789abcdefghijklmnopqrstuvwxyz"+_ 'divide the string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
datLenMod = len(dat$) mod 4
if datLenMod then padding = 4 - datLenMod
for x = 1 to padding
dat$ = dat$ + chr$(0)
next x
for x = 1 to len(dat$) step 4
temp$ = mid$(dat$, x, 4)
for y = 1 to 4
conv = (conv * 256) + asc(mid$(temp$, y, 1))
next y
for convCount = 1 to 5
char = (conv mod 85) + 1
chunk$ = mid$(Z85$, char, 1) + chunk$ '***use of Z85$
conv = int(conv / 85)
next convCount
Format85$ = Format85$ + chunk$
chunk$ = ""
next x
Format85$ = left$(Format85$, len(Format85$) - padding)
end function
sub readWriteNext
call KSA
call delay
filedialog "Open text file", "*.txt", infile$
print "File chosen is ";infile$
filedialog "Save As...", "*.txt", outfile$
print "File chosen is ";outfile$
open infile$ for input as #r
open outfile$ for output as #w
text$ = input$(#r, lof(#r))
alpha$ = unFormat85$(text$)
print #w, alpha$
close #r
close #w
for i = 0 to 7
print space$(i);"Decrypting"
next i
print ""
print "Process Completed"
end sub
function unFormat85$(dat$)
Z85$ = "0123456789abcdefghijklmnopqrstuvwxyz" +_ 'divide string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
padChr$ = right$(Z85$, 1)
datLenMod = len(dat$) mod 5
if datLenMod then padding = 5 - datLenMod
for x = 1 to padding
dat$ = dat$ + padChr$
next x
for x = 1 to len(dat$) step 5
temp$ = mid$(dat$, x, 5)
for y = 1 to 5
t$ = mid$(temp$, y, 1)
conv = (conv * 85) + (instr(Z85$, t$) - 1)
next y
for deconvCount = 1 to 4
char = conv mod 256
chunk$ = chr$(char) + chunk$
conv = int(conv / 256)
next deconvCount
unFormat85$ = unFormat85$ + chunk$
chunk$ = ""
next x
pass$ = left$(unFormat85$, len(unFormat85$) - padding)
unFormat85$ = rxPRGA$(pass$)
end function
function rxPRGA$(inString$) '''psuedo random byte generator
i = 0 :j = 0
for x = 1 to len(inString$)
i = (i + 1) mod 256 '*********
byte = asc(mid$(inString$,x,1))
j = (j + S(i))mod 256
temp = S(i)
S(i) = S(j)
S(j) = temp
t = (S(i) + S(j))mod 256 '''changed real RC4
k = S(t) ''' changed real RC4
ck = byte xor k ''' changed real RC4
char$ = char$ + chr$(ck) ''' changed real RC4
next x
rxPRGA$ = char$
end function
print "Real RC4 File Encryption Base 85 Text"
''Real RC4 File Encryption Base 85 Text
'' Use Hexidecimal Key
global key$, key2$
BackgroundColor$ = "darkcyan"
ForegroundColor$ = "black"
WindowWidth = 300 : WindowHeight = 300
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.enc, "Encrypt", [encrypt], ul, 55, 155, 110, 25
button #main.dec, "Decrypt", [decrypt], ul, 55, 195, 110, 25
button #main.clearKey , "Clear Key", [clearKey], ul, 30, 75, 70, 20
textbox #main.key, 30, 45, 150, 20
statictext #main.encKey, "Encryption Key ", 20, 30, 170, 15
Open "Hex Key Selection " for window as #main
#main "trapclose [quit]"
key$ = "9e3779b9"
#main.key key$
wait
[encrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
close #main
call hexKey$
call readWriteFile
wait
[decrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
close #main
call hexKey$
call readWriteNext
wait
[advise]
notice "A Hex Key is required"
close #main
wait
[clearKey]
#main.key ""
wait
[quit]
close #main
End
sub hexKey$
for i = 1 to len(key$)step 2
chunk$ = mid$(key$,i,2)
byte = hexDec(chunk$)
key2$ = key2$ + chr$(byte)
print chunk$, byte
next i
print:print
print key2$
end sub
sub KSA '''key expansion
dim S(256)
dim K(256)
i = 0: j = 0
for i = 0 to 255
S(i)= i
next i
for i = 0 to 255
K(i)= asc(mid$(key2$,i mod len(key2$)+1))
next i
for i = 0 to 255
j = (j+ S(i)+ K(i))mod 256
temp = S(i)
S(i)= S(j)
S(j)= temp
next i
end sub
sub delay
timer 2000, [timertest]
wait
[timertest]
timer 0
end sub
sub readWriteFile
call KSA
call delay
filedialog "Open text file", "*.txt", infile$
print "File chosen is ";infile$
filedialog "Save As...", "*.txt", outfile$
print "File chosen is ";outfile$
open infile$ for input as #r
open outfile$ for output as #w
text$ = input$(#r, lof(#r))
alpha$ = txPRGA$(text$)
print #w, alpha$;
close #r
close #w
for i = 0 to 7
print space$(i);"Encrypting"
next i
print ""
print "Process Completed"
end sub
function txPRGA$(inString$) '''psuedo random byte generator
i = 0: j = 0
for x = 1 to len(inString$)
i = (i + 1) mod 256 '*********
byte = asc(mid$(inString$,x,1))
j = (j + S(i))mod 256
temp = S(i)
S(i) = S(j)
S(j) = temp
t = (S(i) + S(j))mod 256 '''changed real RC4
k = S(t) ''' changed real RC4
ck = byte xor k ''' changed real RC4
char$ = char$ + chr$(ck) ''' changed real RC4
next x
txPRGA$ = Format85$(char$)
end function
function Format85$(dat$)
Z85$ = "0123456789abcdefghijklmnopqrstuvwxyz"+_ 'divide the string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
datLenMod = len(dat$) mod 4
if datLenMod then padding = 4 - datLenMod
for x = 1 to padding
dat$ = dat$ + chr$(0)
next x
for x = 1 to len(dat$) step 4
temp$ = mid$(dat$, x, 4)
for y = 1 to 4
conv = (conv * 256) + asc(mid$(temp$, y, 1))
next y
for convCount = 1 to 5
char = (conv mod 85) + 1
chunk$ = mid$(Z85$, char, 1) + chunk$ '***use of Z85$
conv = int(conv / 85)
next convCount
Format85$ = Format85$ + chunk$
chunk$ = ""
next x
Format85$ = left$(Format85$, len(Format85$) - padding)
end function
sub readWriteNext
call KSA
call delay
filedialog "Open text file", "*.txt", infile$
print "File chosen is ";infile$
filedialog "Save As...", "*.txt", outfile$
print "File chosen is ";outfile$
open infile$ for input as #r
open outfile$ for output as #w
text$ = input$(#r, lof(#r))
alpha$ = unFormat85$(text$)
print #w, alpha$
close #r
close #w
for i = 0 to 7
print space$(i);"Decrypting"
next i
print ""
print "Process Completed"
end sub
function unFormat85$(dat$)
Z85$ = "0123456789abcdefghijklmnopqrstuvwxyz" +_ 'divide string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
padChr$ = right$(Z85$, 1)
datLenMod = len(dat$) mod 5
if datLenMod then padding = 5 - datLenMod
for x = 1 to padding
dat$ = dat$ + padChr$
next x
for x = 1 to len(dat$) step 5
temp$ = mid$(dat$, x, 5)
for y = 1 to 5
t$ = mid$(temp$, y, 1)
conv = (conv * 85) + (instr(Z85$, t$) - 1)
next y
for deconvCount = 1 to 4
char = conv mod 256
chunk$ = chr$(char) + chunk$
conv = int(conv / 256)
next deconvCount
unFormat85$ = unFormat85$ + chunk$
chunk$ = ""
next x
pass$ = left$(unFormat85$, len(unFormat85$) - padding)
unFormat85$ = rxPRGA$(pass$)
end function
function rxPRGA$(inString$) '''psuedo random byte generator
i = 0 :j = 0
for x = 1 to len(inString$)
i = (i + 1) mod 256 '*********
byte = asc(mid$(inString$,x,1))
j = (j + S(i))mod 256
temp = S(i)
S(i) = S(j)
S(j) = temp
t = (S(i) + S(j))mod 256 '''changed real RC4
k = S(t) ''' changed real RC4
ck = byte xor k ''' changed real RC4
char$ = char$ + chr$(ck) ''' changed real RC4
next x
rxPRGA$ = char$
end function
''Real RC4 File Encryption Base 85 Text
'' Use Hexidecimal Key
global key$, key2$
BackgroundColor$ = "darkcyan"
ForegroundColor$ = "black"
WindowWidth = 300 : WindowHeight = 300
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.enc, "Encrypt", [encrypt], ul, 55, 155, 110, 25
button #main.dec, "Decrypt", [decrypt], ul, 55, 195, 110, 25
button #main.clearKey , "Clear Key", [clearKey], ul, 30, 75, 70, 20
textbox #main.key, 30, 45, 150, 20
statictext #main.encKey, "Encryption Key ", 20, 30, 170, 15
Open "Hex Key Selection " for window as #main
#main "trapclose [quit]"
key$ = "9e3779b9"
#main.key key$
wait
[encrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
close #main
call hexKey$
call readWriteFile
wait
[decrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
close #main
call hexKey$
call readWriteNext
wait
[advise]
notice "A Hex Key is required"
close #main
wait
[clearKey]
#main.key ""
wait
[quit]
close #main
End
sub hexKey$
for i = 1 to len(key$)step 2
chunk$ = mid$(key$,i,2)
byte = hexDec(chunk$)
key2$ = key2$ + chr$(byte)
print chunk$, byte
next i
print:print
print key2$
end sub
sub KSA '''key expansion
dim S(256)
dim K(256)
i = 0: j = 0
for i = 0 to 255
S(i)= i
next i
for i = 0 to 255
K(i)= asc(mid$(key2$,i mod len(key2$)+1))
next i
for i = 0 to 255
j = (j+ S(i)+ K(i))mod 256
temp = S(i)
S(i)= S(j)
S(j)= temp
next i
end sub
sub delay
timer 2000, [timertest]
wait
[timertest]
timer 0
end sub
sub readWriteFile
call KSA
call delay
filedialog "Open text file", "*.txt", infile$
print "File chosen is ";infile$
filedialog "Save As...", "*.txt", outfile$
print "File chosen is ";outfile$
open infile$ for input as #r
open outfile$ for output as #w
text$ = input$(#r, lof(#r))
alpha$ = txPRGA$(text$)
print #w, alpha$;
close #r
close #w
for i = 0 to 7
print space$(i);"Encrypting"
next i
print ""
print "Process Completed"
end sub
function txPRGA$(inString$) '''psuedo random byte generator
i = 0: j = 0
for x = 1 to len(inString$)
i = (i + 1) mod 256 '*********
byte = asc(mid$(inString$,x,1))
j = (j + S(i))mod 256
temp = S(i)
S(i) = S(j)
S(j) = temp
t = (S(i) + S(j))mod 256 '''changed real RC4
k = S(t) ''' changed real RC4
ck = byte xor k ''' changed real RC4
char$ = char$ + chr$(ck) ''' changed real RC4
next x
txPRGA$ = Format85$(char$)
end function
function Format85$(dat$)
Z85$ = "0123456789abcdefghijklmnopqrstuvwxyz"+_ 'divide the string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
datLenMod = len(dat$) mod 4
if datLenMod then padding = 4 - datLenMod
for x = 1 to padding
dat$ = dat$ + chr$(0)
next x
for x = 1 to len(dat$) step 4
temp$ = mid$(dat$, x, 4)
for y = 1 to 4
conv = (conv * 256) + asc(mid$(temp$, y, 1))
next y
for convCount = 1 to 5
char = (conv mod 85) + 1
chunk$ = mid$(Z85$, char, 1) + chunk$ '***use of Z85$
conv = int(conv / 85)
next convCount
Format85$ = Format85$ + chunk$
chunk$ = ""
next x
Format85$ = left$(Format85$, len(Format85$) - padding)
end function
sub readWriteNext
call KSA
call delay
filedialog "Open text file", "*.txt", infile$
print "File chosen is ";infile$
filedialog "Save As...", "*.txt", outfile$
print "File chosen is ";outfile$
open infile$ for input as #r
open outfile$ for output as #w
text$ = input$(#r, lof(#r))
alpha$ = unFormat85$(text$)
print #w, alpha$
close #r
close #w
for i = 0 to 7
print space$(i);"Decrypting"
next i
print ""
print "Process Completed"
end sub
function unFormat85$(dat$)
Z85$ = "0123456789abcdefghijklmnopqrstuvwxyz" +_ 'divide string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
padChr$ = right$(Z85$, 1)
datLenMod = len(dat$) mod 5
if datLenMod then padding = 5 - datLenMod
for x = 1 to padding
dat$ = dat$ + padChr$
next x
for x = 1 to len(dat$) step 5
temp$ = mid$(dat$, x, 5)
for y = 1 to 5
t$ = mid$(temp$, y, 1)
conv = (conv * 85) + (instr(Z85$, t$) - 1)
next y
for deconvCount = 1 to 4
char = conv mod 256
chunk$ = chr$(char) + chunk$
conv = int(conv / 256)
next deconvCount
unFormat85$ = unFormat85$ + chunk$
chunk$ = ""
next x
pass$ = left$(unFormat85$, len(unFormat85$) - padding)
unFormat85$ = rxPRGA$(pass$)
end function
function rxPRGA$(inString$) '''psuedo random byte generator
i = 0 :j = 0
for x = 1 to len(inString$)
i = (i + 1) mod 256 '*********
byte = asc(mid$(inString$,x,1))
j = (j + S(i))mod 256
temp = S(i)
S(i) = S(j)
S(j) = temp
t = (S(i) + S(j))mod 256 '''changed real RC4
k = S(t) ''' changed real RC4
ck = byte xor k ''' changed real RC4
char$ = char$ + chr$(ck) ''' changed real RC4
next x
rxPRGA$ = char$
end function
print "Real RC4 File Encryption Base 85 Text"
''Real RC4 File Encryption Base 85 Text
'' Use Hexidecimal Key
global key$, key2$
BackgroundColor$ = "darkcyan"
ForegroundColor$ = "black"
WindowWidth = 300 : WindowHeight = 300
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.enc, "Encrypt", [encrypt], ul, 55, 155, 110, 25
button #main.dec, "Decrypt", [decrypt], ul, 55, 195, 110, 25
button #main.clearKey , "Clear Key", [clearKey], ul, 30, 75, 70, 20
textbox #main.key, 30, 45, 150, 20
statictext #main.encKey, "Encryption Key ", 20, 30, 170, 15
Open "Hex Key Selection " for window as #main
#main "trapclose [quit]"
key$ = "9e3779b9"
#main.key key$
wait
[encrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
close #main
call hexKey$
call readWriteFile
wait
[decrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
close #main
call hexKey$
call readWriteNext
wait
[advise]
notice "A Hex Key is required"
close #main
wait
[clearKey]
#main.key ""
wait
[quit]
close #main
End
sub hexKey$
for i = 1 to len(key$)step 2
chunk$ = mid$(key$,i,2)
byte = hexDec(chunk$)
key2$ = key2$ + chr$(byte)
print chunk$, byte
next i
print:print
print key2$
end sub
sub KSA '''key expansion
dim S(256)
dim K(256)
i = 0: j = 0
for i = 0 to 255
S(i)= i
next i
for i = 0 to 255
K(i)= asc(mid$(key2$,i mod len(key2$)+1))
next i
for i = 0 to 255
j = (j+ S(i)+ K(i))mod 256
temp = S(i)
S(i)= S(j)
S(j)= temp
next i
end sub
sub delay
timer 2000, [timertest]
wait
[timertest]
timer 0
end sub
sub readWriteFile
call KSA
call delay
filedialog "Open text file", "*.txt", infile$
print "File chosen is ";infile$
filedialog "Save As...", "*.txt", outfile$
print "File chosen is ";outfile$
open infile$ for input as #r
open outfile$ for output as #w
text$ = input$(#r, lof(#r))
alpha$ = txPRGA$(text$)
print #w, alpha$;
close #r
close #w
for i = 0 to 7
print space$(i);"Encrypting"
next i
print ""
print "Process Completed"
end sub
function txPRGA$(inString$) '''psuedo random byte generator
i = 0: j = 0
for x = 1 to len(inString$)
i = (i + 1) mod 256 '*********
byte = asc(mid$(inString$,x,1))
j = (j + S(i))mod 256
temp = S(i)
S(i) = S(j)
S(j) = temp
t = (S(i) + S(j))mod 256 '''changed real RC4
k = S(t) ''' changed real RC4
ck = byte xor k ''' changed real RC4
char$ = char$ + chr$(ck) ''' changed real RC4
next x
txPRGA$ = Format85$(char$)
end function
function Format85$(dat$)
Z85$ = "0123456789abcdefghijklmnopqrstuvwxyz"+_ 'divide the string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
datLenMod = len(dat$) mod 4
if datLenMod then padding = 4 - datLenMod
for x = 1 to padding
dat$ = dat$ + chr$(0)
next x
for x = 1 to len(dat$) step 4
temp$ = mid$(dat$, x, 4)
for y = 1 to 4
conv = (conv * 256) + asc(mid$(temp$, y, 1))
next y
for convCount = 1 to 5
char = (conv mod 85) + 1
chunk$ = mid$(Z85$, char, 1) + chunk$ '***use of Z85$
conv = int(conv / 85)
next convCount
Format85$ = Format85$ + chunk$
chunk$ = ""
next x
Format85$ = left$(Format85$, len(Format85$) - padding)
end function
sub readWriteNext
call KSA
call delay
filedialog "Open text file", "*.txt", infile$
print "File chosen is ";infile$
filedialog "Save As...", "*.txt", outfile$
print "File chosen is ";outfile$
open infile$ for input as #r
open outfile$ for output as #w
text$ = input$(#r, lof(#r))
alpha$ = unFormat85$(text$)
print #w, alpha$
close #r
close #w
for i = 0 to 7
print space$(i);"Decrypting"
next i
print ""
print "Process Completed"
end sub
function unFormat85$(dat$)
Z85$ = "0123456789abcdefghijklmnopqrstuvwxyz" +_ 'divide string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
padChr$ = right$(Z85$, 1)
datLenMod = len(dat$) mod 5
if datLenMod then padding = 5 - datLenMod
for x = 1 to padding
dat$ = dat$ + padChr$
next x
for x = 1 to len(dat$) step 5
temp$ = mid$(dat$, x, 5)
for y = 1 to 5
t$ = mid$(temp$, y, 1)
conv = (conv * 85) + (instr(Z85$, t$) - 1)
next y
for deconvCount = 1 to 4
char = conv mod 256
chunk$ = chr$(char) + chunk$
conv = int(conv / 256)
next deconvCount
unFormat85$ = unFormat85$ + chunk$
chunk$ = ""
next x
pass$ = left$(unFormat85$, len(unFormat85$) - padding)
unFormat85$ = rxPRGA$(pass$)
end function
function rxPRGA$(inString$) '''psuedo random byte generator
i = 0 :j = 0
for x = 1 to len(inString$)
i = (i + 1) mod 256 '*********
byte = asc(mid$(inString$,x,1))
j = (j + S(i))mod 256
temp = S(i)
S(i) = S(j)
S(j) = temp
t = (S(i) + S(j))mod 256 '''changed real RC4
k = S(t) ''' changed real RC4
ck = byte xor k ''' changed real RC4
char$ = char$ + chr$(ck) ''' changed real RC4
next x
rxPRGA$ = char$
end function