01-09-2004, 02:25 AM
I wrote this a while back for the encryption challenge. Nobody ever said whether it was good or not, but I thought it was kinda neat, so here if ya wanna take a look at it =)
It doesn't use a key. It's an ascii-value shifter, but it doesn't shift by letter (therefore, E will not always become A, for example). Instead it uses both the ascii value of the (already encrypted) character before it, and that of the character after it to determine how much the shift is. Furthermore, it uses the location of the letter within the string to further alter the ASC value.
I feel like this would be very difficult to decrypt without knowing the formula.
*peace*
Meg.
It doesn't use a key. It's an ascii-value shifter, but it doesn't shift by letter (therefore, E will not always become A, for example). Instead it uses both the ascii value of the (already encrypted) character before it, and that of the character after it to determine how much the shift is. Furthermore, it uses the location of the letter within the string to further alter the ASC value.
I feel like this would be very difficult to decrypt without knowing the formula.
*peace*
Meg.
Code:
tt = 1000
'*** ^^ CHANGE THIS VALUE TO AFFECT SPEED ^^ ***
CLS
LINE INPUT "Enter string to encrypt: ", i$
'******************* ENCRYPT ********************
LOCATE 3, 1: PRINT i$
FOR x% = 1 TO LEN(i$)
IF x% > 1 THEN pre$ = MID$(i$, x% - 1, 1) ELSE pre$ = " "
IF x% < LEN(i$) THEN aft$ = MID$(i$, x% + 1, 1) ELSE aft$ = " "
k% = (ASC(pre$) + ASC(aft$)) \ 2
k% = k% XOR x%
n% = ASC(MID$(i$, x%, 1))
n% = n% + k%
DO
IF n% > 126 THEN n% = n% - 95
LOOP UNTIL n% < 127
i$ = LEFT$(i$, x% - 1) + CHR$(n%) + RIGHT$(i$, LEN(i$) - x%)
FOR t = 1 TO tt
LOCATE 3, x%: PRINT CHR$(INT(RND * 95) + 32)
NEXT t
LOCATE 3, 1: PRINT i$; k%
NEXT x%
LOCATE 5, 1: PRINT "Encrypted string: "; i$
'****************** UNENCRYPT *******************
LOCATE 7, 1: PRINT i$
FOR x% = LEN(i$) TO 1 STEP -1
IF x% > 1 THEN pre$ = MID$(i$, x% - 1, 1) ELSE pre$ = " "
IF x% < LEN(i$) THEN aft$ = MID$(i$, x% + 1, 1) ELSE aft$ = " "
k% = (ASC(pre$) + ASC(aft$)) \ 2
k% = k% XOR x%
n% = ASC(MID$(i$, x%, 1))
n% = n% - k%
DO
IF n% < 32 THEN n% = n% + 95
LOOP UNTIL n% > 31
i$ = LEFT$(i$, x% - 1) + CHR$(n%) + RIGHT$(i$, LEN(i$) - x%)
FOR t = 1 TO tt
LOCATE 7, x%: PRINT CHR$(INT(RND * 95) + 32)
NEXT t
LOCATE 7, 1: PRINT i$; k%
NEXT x%
LOCATE 9, 1: PRINT "Unencrypted string: "; i$