08-16-2005, 07:32 PM
Heres my first try... Uses a frequency setting like 2way radios, cept its used to scramble the string... pretty fast if you ask me, not sure if its good enough or not..
Edit: Most of the code is a speed test/example... :roll:
Edit: Most of the code is a speed test/example... :roll:
Code:
DECLARE SUB ScramleMsg(Msg AS STRING, Frq AS INTEGER)
DECLARE SUB DeScramleMsg(Msg AS STRING, Frq AS INTEGER)
'##################################################
'## EXAMPLE #####################
'##################################################
SCREEN 14, 32
Msge$ = "Hello, world! This is a example of my scrambler/encrypter! Testing with large string to see how fast this operates. One more sentance should do it for a nice test!"
COLOR RGB(255, 255, 255)
PRINT "Message: ";
COLOR RGB(255, 255, 0)
PRINT Msge$
PRINT
COLOR RGB(255, 255, 255)
PRINT "Press Key to scramble..."
SLEEP
CLS
ST1! = TIMER
'ScramleMsg(Message_String$, Frequency Setting)
' Returns string given scrambled...
' Scrable is set by a frequency type setting
ScramleMsg(Msge$, 100)
FT1! = TIMER
TT1! = FT1! - ST1!
PRINT "Scrambled Message: ";
COLOR RGB(255, 255, 0)
PRINT Msge$
PRINT
COLOR RGB(255, 255, 255)
PRINT "Press key to return message... "
SLEEP
ST2! = TIMER
'DeScramleMsg(Message_String$, Frequency Setting)
' Returns scrambled sting as it was before the scramble..
' Scrable is set by a frequency type setting
' Frequency must be the same as the one used in the Scramble call...
DeScramleMsg(Msge$, 100)
FT2! = TIMER
TT2! = FT2! - ST2!
PRINT "Unscrambled Message: ";
COLOR RGB(255, 255, 0)
PRINT Msge$
PRINT
PRINT
COLOR RGB(255,255,255)
PRINT "Total Scrambling time:";
COLOR RGB(0, 255, 0)
PRINT TT1!
PRINT ST1!; " <- Started.."
PRINT FT1!; " <- Finished."
PRINT
COLOR RGB(255,255,255)
PRINT "Total DeScrambling time:";
COLOR RGB(0, 255, 0)
PRINT TT2!
PRINT ST2!; " <- Started.."
PRINT FT2!; " <- Finished."
SLEEP
'##################################################
'################################
'##################################################
SUB ScramleMsg(Msg AS STRING, Frq AS INTEGER)
FOR i = 1 TO LEN(Msg)
S$ = MID$(Msg, i, 1)
N = ASC(S$)
N = (N + Frq)MOD 255
STORE$ += CHR$(N)
NEXT
Msg = STORE$
STORE$ = ""
END SUB
SUB DeScramleMsg(Msg AS STRING, Frq AS INTEGER)
FOR i = 1 TO LEN(Msg)
S$ = MID$(Msg, i, 1)
N = ASC(S$)
N = (N - Frq)
IF N < 0 THEN N = 255 - N
STORE$ += CHR$(N)
NEXT
Msg = STORE$
STORE$ = ""
END SUB