10-27-2003, 06:44 PM
For now I had nothing to do so I wrote down a little idea I had
for encryption:
The function takes the char at a position in msg$ and XOR's it with
char in key$ at the same position (Note the WHILE line in the
function)
I just wonder is this a good way of encryption? (If the enemy don't
get the key), Because in some movie somebody said that it would
take thousands (or something) of years to decrypt a message with
a 128 bit (or was it byte?) key, (Yeah I know things in movies are
seldom true but ...whatever)
example
PRINT dencrypt ("Hello","123") 'outputs "yW_]]" to screen
PRINT dencrypt ("yW_]]","123") 'outputs "Hello" to screen
for encryption:
Code:
'encryption/decryption function by red_Marvin
DECLARE FUNCTION dencrypt$ (msg$, key$)
FUNCTION dencrypt$ (msg$, key$)
FOR msgpos = 1 TO LEN(msg$)
keypos = msgpos
WHILE keypos > LEN(key$): keypos = keypos - LEN(key$): WEND
c$ = MID$(msg$, msgpos, 1)
e$ = MID$(key$, keypos, 1)
ec$ = CHR$(ASC(c$) XOR ASC(e$))
emsg$ = emsg$ + ec$
NEXT
dencrypt$ = emsg$
END FUNCTION
The function takes the char at a position in msg$ and XOR's it with
char in key$ at the same position (Note the WHILE line in the
function)
I just wonder is this a good way of encryption? (If the enemy don't
get the key), Because in some movie somebody said that it would
take thousands (or something) of years to decrypt a message with
a 128 bit (or was it byte?) key, (Yeah I know things in movies are
seldom true but ...whatever)
example
PRINT dencrypt ("Hello","123") 'outputs "yW_]]" to screen
PRINT dencrypt ("yW_]]","123") 'outputs "Hello" to screen