# Qbasicnews.com

Full Version: Let's have an encryption CHALLENGE!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9
So what you mean is that you make up a different key each time, right? What's to stop the computer doing the same?
Here's something i come up with... when i wasn't sober....

DECLARE FUNCTION Rotate\$ (Text\$)
DECLARE FUNCTION Cipher\$ (Text\$, Key\$)

CLS

NormalString\$ = "I Can't Goto Sleep The Clowns Will Eat Me"
Key\$ = "QbAsIcNeWs..."

CipherdText\$ = Cipher\$(NormalString\$, Key\$)
DeCipherd\$ = Cipher\$(CipherdText\$, Key\$)

PRINT "Orignal- "; NormalString\$
PRINT "Cipherd- "; CipherdText\$
PRINT "DeCipherd-> "; DeCipherd\$

PRINT STRING\$(80, "-")

PRINT "Orginal Len-"; LEN(NormalString\$)
PRINT "Cipherd Len-"; LEN(CipherdText\$)
PRINT "DeCipherd Len->"; LEN(DeCipherd\$)

SYSTEM

DEFINT A-Z
FUNCTION Cipher\$ (Text\$, Key\$)

DIM L AS LONG
DIM D AS LONG
DIM X AS LONG

X& = 1

OldKey\$ = Key\$

FOR I = 1 TO LEN(Text\$)

Key.I = Key.I + 1
IF Key.I > LEN(Key\$) THEN Key.I = 1

C = (ASC(MID\$(Text\$, I, 1)) XOR (ASC(MID\$(Key\$, Key.I, 1)) * I)) AND 255
Enc\$ = Enc\$ + CHR\$©

L = L + 7
D = D + 4
X = ((X + (SQR((X XOR (D MOD X))) * (64 + (L * D) - I))) AND 4095) XOR I

IF X Mod (L + D) < I THEN Key\$ = Rotate\$(Key\$)

NEXT

Key\$ = OldKey\$

Cipher\$ = Enc\$

END FUNCTION

FUNCTION Rotate\$ (Text\$)

N\$ = SPACE\$(LEN(Text\$))

FOR I = 2 TO LEN(Text\$)

MID\$(N\$, I - 1) = MID\$(Text\$, I, 1)

NEXT

MID\$(N\$, LEN(N\$)) = MID\$(Text\$, 1, 1)

Rotate\$ = N\$

END FUNCTION
one and a half weeks, since i'll be disappearing for a while..
Excellent, there's been a lot of interest, hasn't there. But I thought this thread had died... so it's good.
Yes i know it's been 6 days since the last post and that this thread is most likely dead but i have a very bad encryption program. and i want to post it

Code:
```CLS INPUT text\$ x\$ = " ~!@#\$%^&*()_+{}|:<>?`-=[]\;',./1234567890qetuoadgjlxvnwryipsfhkzcbmMBCZKHFSPIYRWNVXLJGDAOUTEQ" x2\$ = "QETUOADGJLXVNWRYIPSFHKZCBMmbczkhfspiyrwnvxljgdaouteq0987654321/.,';\][=-`?><:|}{+_)(*&^%\$#@!~" FOR i = 1 TO LEN(text\$) tmp = INSTR(x\$, MID\$(text\$, i, 1)) IF tmp <> 0 THEN   tmp2\$ = MID\$(x2\$, tmp, 1)   f\$ = f\$ + tmp2\$ END IF NEXT PRINT f\$```

Yes very simple. but if you are dumb it may take you a minute or two to figure it out. j/k. :wink:
Out of interest, is anyone collecting an archive of these programs, because I'll happily do it for QBNZ (I have a whopping 30+ files to add, which have been made available to me in the space of one week!)

If I don't hear anything by tomorrow I'll do it anyway, but of course you have the right to request that it disappears from QBNZ at any time.
without any effort, I can declare Mango the winner (surely a no-brainer?), and everyone else ties second place.
YEah 2nd place!!!!!
Why complicate things, you can't break any decryption without the key no matter what. So an XOR cryption will do fine for most things. And it's small too.

Code:
```defint a-z function xorEncrypt\$ ( src as string, ekey as string )     dim i as integer     dim dst as string     dim keyLen as integer              keyLen = len( ekey )          for  i = 1 to len ( src )         dst = dst + chr\$( asc(mid\$( src, i, 1 )) xor _                           asc(mid\$( ekey, i mod keyLen + 1, 1 )) )     next i          xorEncrypt\$ = dst          end function defint a-z function xorDecrypt\$ ( src as string, ekey as string )     dim i as integer     dim dst as string     dim keyLen as integer              keyLen = len( ekey )          for  i = 1 to len ( src )         dst = dst + chr\$( asc(mid\$( src, i, 1 )) xor _                           asc(mid\$( ekey, i mod keyLen + 1, 1 )) )     next i          xorDecrypt\$ = dst          end function```
Quote:Why complicate things, you can't break any decryption without the key no matter what. So an XOR cryption will do fine for most things. And it's small too.
Incorrect. I broke the first encryption technique using english language letter frequency.
Pages: 1 2 3 4 5 6 7 8 9