xcoder
Member in Training
Posts: 56
|
Post by xcoder on Apr 6, 2023 10:31:02 GMT
global key$, key2$
'Text Encryption ARC4 stream cipher
'author = xcoder
' Just paste text into the texteditor and press encrypt button
'Uses hexidecimal Text Format that is Word Processor and Email compatible
nomainwin
global key$, key2$
WindowWidth = 600 : WindowHeight = 400
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
texteditor #main.text, 200, 20, 360, 320
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
button #main.dec , "Clear Text", [clearText], ul, 110, 75, 70, 20
button #main.refresh , "Delete Encrypted File", [refresh], ul, 40, 240, 135, 25
button #main.copytext , "Copy Text", [copytext], ul, 75, 105, 60, 25
textbox #main.key, 30, 45, 150, 20
statictext #main.editor, "Type or Paste Text Here", 335, 5, 190, 15
statictext #main.encKey, "Encryption Key (Hex Characters)", 20, 30, 170, 15
Open "ARC4 Type Stream Encryptor " for window as #main
#main "trapclose [quit]"
key$ = "9e3779b9a1b2c3d4" ''' default key if none entered
prompt "Enter hexcidecimal Key"; key$ '''any number of hex characters
#main.key key$
#main.text "!autoresize"
if fileExists(DefaultDir$, "textEditor") then
open "textEditor" for input as #1
#main.text , text$ 'read from textEditor
close #1
#main.text "!origin 0 0" 'reset cursor
end if
wait
[encrypt]
if cript = 1 then [decrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
#main.text "!contents? text$" ' read from textEditor
call hexKey$
call KSA
alpha$ = txPRGA$(text$) '***** encrypt
#main.text "!cls"
cript = 1
#main.text alpha$ 'write to textEditor
open "textEditor" for output as #1
#1 alpha$
close #1
#main.text "!origin 0 0" 'reset cursor
wait
[decrypt]
#main.key "!contents? key$"
if key$ = "" then [advise]
#main.text "!contents? text$" 'read from textEditor
call hexKey$
call KSA
bravo$ = hex2Text$(text$) '***** decrypt
#main.text "!cls"
cript = 0
#main.text bravo$ 'write to textEditor
open "textEditor"for output as #1
#1 bravo$
close #1
#main.text "!origin 0 0" 'reset cursor
wait
[clearKey]
#main.key ""
wait
[clearText]
#main.text "!cls"
wait
[refresh]
if fileExists(DefaultDir$, "textEditor") then kill DefaultDir$;"\textEditor"
#main.text "!cls"
wait
[copytext]
#main.text "!selectall"
#main.text "!copy"
wait
[quit]
close #main
End
[advise]
notice "Key is required"
close #main
End
print "------------------------------------------------------------------------------------------------------------"
'function for checking file existence
function fileExists(path$, filename$)
dim info$(0, 0)
files path$, filename$, info$()
fileExists = val(info$(0, 0)) 'non zero is true
end function
sub hexKey$
print "Hex" + space$(5) + "Decimal"
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 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
print "############## Encryption Functions ##################"
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
St = (S(i) + S(j))mod 256
k = byte xor St
char$ = char$ + chr$(k)
next x
txPRGA$ = text2Hex$(char$)
end function
function text2Hex$(cipher$)
for i = 1 to len(cipher$) 'encrypted text
byte = asc(mid$(cipher$,i,1)) 'encrypted ascii
hex$ = decHex$(byte)
hex$ = right$("0" + hex$,2)
max$ = max$ + hex$ 'encrypted hex
next i
text2Hex$ = max$
end function
print "############# Decryption functions ###############"
function hex2Text$(hex$)
for i = 1 to len(hex$)step 2 'encrypted hex
chunk$ = mid$(hex$,i,2)
byte = hexDec(chunk$) 'encrypted ascii
text$ = text$ + chr$(byte) 'encrypted text
next i
hex2Text$= rxPRGA$(text$)
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
St = (S(i) + S(j))mod 256
k = byte xor St
char$ = char$ + chr$(k)
next x
rxPRGA$ = char$
end function
|
|
|
Post by xxgeek on Apr 6, 2023 16:41:40 GMT
xcoder, the resulting encrypted text was adding a character at the end.
By trimming the text coming from the texteditor before encrypting, and before decrypting it has fixed the issue.
Seems to be working well, and I like this method of encryption. When I try changing one or 2 characters in the key, the resulting encrypted text remains very unreadable. Previous versions have given away some of the original text in the results.
'Text Encryption ARC4 stream cipher 'author = xcoder ' Just paste text into the texteditor and press encrypt button 'Uses hexidecimal Text Format that is Word Processor and Email compatible
nomainwin global key$, key2$ WindowWidth = 600 : WindowHeight = 400 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) texteditor #main.text, 200, 20, 360, 320 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 button #main.dec , "Clear Text", [clearText], ul, 110, 75, 70, 20 button #main.refresh , "Delete Encrypted File", [refresh], ul, 40, 240, 135, 25 button #main.copytext , "Copy Text", [copytext], ul, 75, 105, 60, 25 textbox #main.key, 30, 45, 150, 20 statictext #main.editor, "Type or Paste Text Here", 335, 5, 190, 15 statictext #main.encKey, "Encryption Key (Hex Characters)", 20, 30, 170, 15 Open "ARC4 Type Stream Encryptor " for window as #main #main "trapclose [quit]" key$ = "9e3779b9a1b2c3d4" ''' default key if none entered prompt "Enter hexcidecimal Key"; key$ '''any number of hex characters #main.key key$ #main.text "!autoresize" if fileExists(DefaultDir$, "textEditor") then open "textEditor" for input as #1 #main.text , text$ 'read from textEditor close #1 #main.text "!origin 0 0" 'reset cursor end if wait
[encrypt] if cript = 1 then [decrypt] #main.key "!contents? key$" if key$ = "" then [advise] #main.text "!contents? text$" ' read from textEditor text$=trim$(text$) '...............Added by xxgeek call hexKey$ call KSA alpha$ = txPRGA$(text$) '***** encrypt #main.text "!cls" cript = 1 #main.text alpha$ 'write to textEditor open "textEditor" for output as #1 #1 alpha$ close #1 #main.text "!origin 0 0" 'reset cursor wait
[decrypt] #main.key "!contents? key$" if key$ = "" then [advise] #main.text "!contents? text$" 'read from textEditor text$=trim$(text$) '...........ADDED by xxgeek call hexKey$ call KSA bravo$ = hex2Text$(text$) '***** decrypt #main.text "!cls" cript = 0 #main.text bravo$ 'write to textEditor open "textEditor"for output as #1 #1 bravo$ close #1 #main.text "!origin 0 0" 'reset cursor wait
[clearKey] #main.key "" wait
[clearText] #main.text "!cls" wait
[refresh] if fileExists(DefaultDir$, "textEditor") then kill DefaultDir$;"\textEditor" #main.text "!cls" wait
[copytext] #main.text "!selectall" #main.text "!copy" wait
[quit] close #main End
[advise] notice "Key is required" close #main End
print "------------------------------------------------------------------------------------------------------------"
'function for checking file existence function fileExists(path$, filename$) dim info$(0, 0) files path$, filename$, info$() fileExists = val(info$(0, 0)) 'non zero is true end function
sub hexKey$ print "Hex" + space$(5) + "Decimal" 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 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
print "############## Encryption Functions ##################"
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 St = (S(i) + S(j))mod 256 k = byte xor St char$ = char$ + chr$(k) next x txPRGA$ = text2Hex$(char$) end function
function text2Hex$(cipher$) for i = 1 to len(cipher$) 'encrypted text byte = asc(mid$(cipher$,i,1)) 'encrypted ascii hex$ = decHex$(byte) hex$ = right$("0" + hex$,2) max$ = max$ + hex$ 'encrypted hex next i text2Hex$ = max$ end function
print "############# Decryption functions ###############"
function hex2Text$(hex$) for i = 1 to len(hex$)step 2 'encrypted hex chunk$ = mid$(hex$,i,2) byte = hexDec(chunk$) 'encrypted ascii text$ = text$ + chr$(byte) 'encrypted text next i hex2Text$= rxPRGA$(text$) 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 St = (S(i) + S(j))mod 256 k = byte xor St char$ = char$ + chr$(k) next x rxPRGA$ = char$ end function '
|
|
|
Post by xxgeek on Apr 6, 2023 17:59:25 GMT
I've been trying to put together a useful application that uses your encryption code xcoder. This is what I have so far, but I'm not sure what else it needs, although I feel it needs "something'
Any ideas? Play around with the code and let me know if there are any problems you notice.
'Text Encryption 'author = xcoder 'Date Feb 2023 'Purpose - To encrypt blocks of text, for example > Just Basic Programs nomainwin global key$, key2$ keyLength$(1) = "8" keyLength$(2) = "12" keyLength$(3) = "16" keyLength$(4) = "24" keyLength$(5) = "32" keyLength$(6) = "48" keyLength$(7) = "64" keyLength$(8) = "96" keyLength$(9) = "128" WindowWidth = 900 : WindowHeight = 500 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) menu #main,"File" , "Open File", [openFile], "Save As ", [saveAs], "Exit Program", [quit] texteditor #main.text, 210, 70, 670, 375 texteditor #main.hiddenText, 0, 0, 0, 0 combobox #main.keyLength, keyLength$(), [keyLength], 190, 0, 55, 25 button #main.generate, "Generate Random Key", [generate], ul, 10, 0, 130, 23 button #main.defkey, "Use Default Key", [defKey], ul, 260, 0, 120, 23 button #main.enc, "Encrypt Text", [encrypt], ul, 55, 270, 90, 45 button #main.dec, "Decrypt Text", [decrypt], ul, 55, 325, 90, 45 button #main.copykey, "Copy Key", [copyKey], ul, 10, 125, 70, 20 button #main.clearKey , "Clear Key", [clearKey], ul, 10, 95, 70, 20 button #main.dec , "Clear Text", [clearText], ul, 125, 95, 70, 20 button #main.copytext , "Copy Text", [copytext], ul, 125, 125, 70, 20 button #main.open , "Open File", [openFile], ul, 65, 220, 70, 30 button #main.saveas , "Save Text", [saveAs], ul, 125, 160, 70, 30 button #main.saveKey , "Save Key", [saveKey], ul, 10, 160, 70, 30 textbox #main.key, 80, 30, 810, 20 statictext #main.length, "Length", 145, 5, 35, 20 statictext #main.editor, "Type or Paste Text Below", 370, 55, 190, 15 statictext #main.encKey, " Default Key", 8, 35, 70, 15 statictext #main.lines, "", 700, 55, 150, 15 Open "Encryptor - by xcoder" for window as #main #main "trapclose [quit]" defKey$ = "9e3779b9a1b2c3d4" ''' default key if none entered prompt "Enter hexcidecimal Key"; defKey$ '''any number of hex characters #main.key key$ #main.text "!autoresize" if fileExists(DefaultDir$, "textEditor") then open "textEditor" for input as #1 #main.text , text$ 'read from textEditor close #1 #main.text "!origin 0 0" 'reset cursor end if length = 16 'initial default key length key$ = defKey$ #main.key defKey$ #main.text "!autoresize" #main.keyLength "select 16" wait
[defKey] #main.key defKey$ #main.encKey " Default Key" wait
[keyLength] #main.keyLength "selection? length$" length = val(length$) wait
[encrypt] if cript = 1 then [decrypt] #main.key "!contents? key$" if key$ = "" then [advise] #main.text "!contents? text$" ' read from textEditor text$=trim$(text$) '...............Added by xxgeek call hexKey$ call KSA alpha$ = txPRGA$(text$) '***** encrypt #main.text "!cls" cript = 1 #main.text alpha$ 'write to textEditor open "textEditor" for output as #1 #1 alpha$ close #1 #main.text "!origin 0 0" 'reset cursor wait
[decrypt] #main.key "!contents? key$" if key$ = "" then [advise] #main.text "!contents? text$" 'read from textEditor text$=trim$(text$) '...........ADDED by xxgeek call hexKey$ call KSA bravo$ = hex2Text$(text$) '***** decrypt #main.text "!cls" cript = 0 #main.text bravo$ 'write to textEditor open "textEditor"for output as #1 #1 bravo$ close #1 #main.text "!origin 0 0" 'reset cursor wait
[generate] #main.encKey "Random Key" key$ = "" : #main.key "!selectall" : #main.key "" keyCharStr$ = "0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F" for x = 1 to length intNum = int(rnd(1)*22)+1 hexNum$ = word$(keyCharStr$, intNum) key$ = key$;hexNum$ next x #main.key key$ wait
[openFile] #main.text "!cls" filedialog "Open \ Select a File", DefaultDir$; "\*.enc;*.key;*.txt;*.bas", openFilename$ if openFilename$ = "" then wait open openFilename$ for input as #1 text$ = input$(#1,lof(#1)) if right$(openFilename$, 4) = ".key" then #main.key text$ else #main.text text$ close #1 #main.text "!lines numLines"; #main.lines numLines;" Lines " #main.text "!origin 0 0" wait
[saveAs] #main.text "!contents? text$" filedialog "Save As...", "*.enc", fileName$ if fileName$ = "" then wait open fileName$ for output as #1 #1 text$ close #1 wait
[saveKey] #main.key "!contents? key$" filedialog "Save As...", "*.key", fileName$ if fileName$ = "" then wait open fileName$ for output as #1 #1 key$ close #1 wait
[clearKey] #main.key "" wait
[clearText] #main.text "!cls" cript = 0 wait
[copytext] #main.text "!selectall" #main.text "!copy" wait
[copyKey] #main.key "!contents? key$" #main.hiddenText key$ #main.hiddenText "!selectall" #main.hiddenText "!copy" #main.hiddenText "!cls" wait
[quit] close #main End
'function for checking file existence function fileExists(path$, filename$) dim info$(0, 0) files path$, filename$, info$() fileExists = val(info$(0, 0)) 'non zero is true end function
sub hexKey$ print "Hex" + space$(5) + "Decimal" 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 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
print "############## Encryption Functions ##################"
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 St = (S(i) + S(j))mod 256 k = byte xor St char$ = char$ + chr$(k) next x txPRGA$ = text2Hex$(char$) end function
function text2Hex$(cipher$) for i = 1 to len(cipher$) 'encrypted text byte = asc(mid$(cipher$,i,1)) 'encrypted ascii hex$ = decHex$(byte) hex$ = right$("0" + hex$,2) max$ = max$ + hex$ 'encrypted hex next i text2Hex$ = max$ end function
print "############# Decryption functions ###############"
function hex2Text$(hex$) for i = 1 to len(hex$)step 2 'encrypted hex chunk$ = mid$(hex$,i,2) byte = hexDec(chunk$) 'encrypted ascii text$ = text$ + chr$(byte) 'encrypted text next i hex2Text$= rxPRGA$(text$) 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 St = (S(i) + S(j))mod 256 k = byte xor St char$ = char$ + chr$(k) next x rxPRGA$ = char$ end function '
|
|
xcoder
Member in Training
Posts: 56
|
Post by xcoder on Apr 6, 2023 20:13:50 GMT
Thanks for the tip about trimming text. concerning generating random keys, see my post titled "Key Generator." One thing I must bring to everyone's attention is that this code will encrypt when using text characters as the key. However this creates extremely weak encryption and functions more like a simple XOR scrambler. For example: key: hello The hex character (e) functions as a key. If there are multiple hex characters in the text, then only the final hex character functions as the key. for example: key: hello world The final hex character (d) functions as the key.
If there are no hex characters, then zero(0) functions as the key. For strong encryption, use hex characters as the key. By the way, this code is an approximation of the famous RC4 cipher explained on wikipedia.
|
|
xcoder
Member in Training
Posts: 56
|
Post by xcoder on Apr 7, 2023 17:57:28 GMT
'Text Encryption ARC4 stream cipher 'author = xcoder ' This version allows use of plain text pass words as the "Key" ^^^^^^^^^^^^ ' Just paste text into the texteditor and press encrypt button 'Uses hexidecimal Text Format that is Word Processor and Email compatible nomainwin global key$, key2$ WindowWidth = 600 : WindowHeight = 400 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) texteditor #main.text, 200, 20, 360, 320 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 button #main.dec , "Clear Text", [clearText], ul, 110, 75, 70, 20 button #main.refresh , "Delete Encrypted File", [refresh], ul, 40, 240, 135, 25 button #main.copytext , "Copy Text", [copytext], ul, 75, 105, 60, 25 textbox #main.key, 30, 45, 150, 20 statictext #main.editor, "Type or Paste Text Here", 335, 5, 190, 15 statictext #main.encKey, "Encryption Key ", 20, 30, 170, 15 Open "ARC4 Type Stream Encryptor " for window as #main #main "trapclose [quit]"
key$ = "MyFavoritePassWord" ''' default key if none entered prompt "Enter a Password"; key$ '''any number of hex characters #main.key key$ #main.text "!autoresize" if fileExists(DefaultDir$, "textEditor") then open "textEditor" for input as #1 #main.text , text$ 'read from textEditor close #1 #main.text "!origin 0 0" 'reset cursor end if
wait [encrypt] if cript = 1 then [decrypt] #main.key "!contents? key$" if key$ = "" then [advise] #main.text "!contents? text$" ' read from textEditor text$ = trim$(text$) call keyPass '''^^^^^^^^^^^^^ modified call KSA alpha$ = txPRGA$(text$) '***** encrypt #main.text "!cls" cript = 1 #main.text alpha$ 'write to textEditor open "textEditor" for output as #1 #1 alpha$ close #1 #main.text "!origin 0 0" 'reset cursor
wait [decrypt] #main.key "!contents? key$" if key$ = "" then [advise] #main.text "!contents? text$" 'read from textEditor text$ = trim$(text$) call keyPass '''^^^^^^ modified call KSA bravo$ = hex2Text$(text$) '***** decrypt #main.text "!cls" cript = 0 #main.text bravo$ 'write to textEditor open "textEditor"for output as #1 #1 bravo$ close #1 #main.text "!origin 0 0" 'reset cursor
wait [clearKey] #main.key "" wait [clearText] #main.text "!cls" wait [refresh] if fileExists(DefaultDir$, "textEditor") then kill DefaultDir$;"\textEditor" #main.text "!cls" wait [copytext] #main.text "!selectall" #main.text "!copy" wait [quit] close #main End [advise] notice "Key is required" close #main End
print "------------------------------------------------------------------------------------------------------------"
'function for checking file existence function fileExists(path$, filename$) dim info$(0, 0) files path$, filename$, info$() fileExists = val(info$(0, 0)) 'non zero is true end function
sub keyPass key2$ = key$ 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
print "############## Encryption Functions ##################"
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 St = (S(i) + S(j))mod 256 k = byte xor St ''' xor text bytes with St (psuedo random bytes) char$ = char$ + chr$(k) next x txPRGA$ = text2Hex$(char$) end function
function text2Hex$(cipher$) for i = 1 to len(cipher$) 'encrypted text byte = asc(mid$(cipher$,i,1)) 'encrypted ascii hex$ = decHex$(byte) hex$ = right$("0" + hex$,2) max$ = max$ + hex$ 'encrypted hex next i text2Hex$ = max$ end function
print "############# Decryption functions ###############"
function hex2Text$(hex$) for i = 1 to len(hex$)step 2 'encrypted hex chunk$ = mid$(hex$,i,2) byte = hexDec(chunk$) 'encrypted ascii text$ = text$ + chr$(byte) 'encrypted text next i hex2Text$= rxPRGA$(text$) 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 St = (S(i) + S(j))mod 256 k = byte xor St ''' xor text bytes with St (psuedo random bytes) char$ = char$ + chr$(k) next x rxPRGA$ = char$ end function
|
|