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
hmm, didnt think of that, thanks Smile
I'd never think of doing it like that.... i'd use len to check the length and then see how many zeroes I need.
For clarification...

This has to be reversable? Or could I write an hmac md5 algorithm and be done with it?

Easiest way would be to take the password and the key and simply rotate the letters up by the key. This is often used in cryptography for good reversable encryption, and has been used to transmit confidential messages.

Basically...

Code:
M Y N A M E I S W H A T <-- message
C A T C A T C A T C A T
-----------------------
O Y G C M X K S P J A M

Or...

Code:
key$ = "cat"
text$ = "mynameiswhat"

IF LEN(key$) < LEN(text$) THEN
   longkey$ = ""

   FOR i% = 0 TO LEN(text$) \ LEN(key$)
      longkey$ = longkey$ + key$
   NEXT i%
ELSE
   longkey$ = key$
END IF

result$ = ""
FOR i% = 1 TO LEN(text$)
   x% = ASC(UCASE$(MID$(text$, i%, 1))) + ASC(UCASE$(MID$(longkey$, i%, 1))) - 65

   IF x% > ASC("Z") THEN x% = x% - 26

   result$ = result$ + CHR$(x%)
NEXT i%

PRINT result$

Result:
OYGCMXKSPJAM

It can easily be decrypted by subtracting with the key.

-[Unknown]
I know, I wrote such a decrypter before. Finds the key length then decrypts.

Ideally it shouldn't be breakable by a simple method, or any method at all, without the key.
Quote:I know, I wrote such a decrypter before. Finds the key length then decrypts.

Ideally it shouldn't be breakable by a simple method, or any method at all, without the key.

It can't be...... it's reversible only with the key - otherwise you have to plug and chug with a supercomputer and never know if you are right.

It can be decrypted with shorter keys and longer messages, but...

-[Unknown]
I already did a key one... see above. agamemnus hasn't posted a decoding program for it yet.
DISCLAIMER:

no... i am still waiting for someone to tell me how to combine ugl and the other library...

I may have lost interest in this thread.
Quote:I'd never think of doing it like that.... i'd use len to check the length and then see how many zeroes I need.

That's what my code example is doing. The idea is to do it all on one line of code.

Yes, to be more elegant, you could do a CASE on the length. But that would be several lines of code. My theory is that the more lines of code to do something, the more chance of bugs. Within reason of course, I don't mean to have one line of code with more than 2 or 3 operations that spans more than 100 characters just to get it all on one line.

Why don't you show us your example for doing it.
*****
Oi, my method uses a very long key... what's wrong with it? Assume I don't add those zeroes on each character.
Well then, anyone broke mine yet?

Code:
FUNCTION KT.ENC.DifCipher$(ToCipher AS STRING, Frequency AS INTEGER)
   'a completely new ciphering method -> Dif Ciphering
   'by Neo Deus Ex Machina

   'I thought of this ciphering, it's completely new ;) lol
   'It uses the difference with a sequent character from the base character
   freqnow = Frequency
   basechar$ = ""
   ans$ = ""
   FOR i = 1 TO LEN(ToCipher)
                IF freqnow = Frequency THEN
                   freqnow = 1
                   basechar$ = MID$(ToCipher, i, 1)
                   ans$ = ans$ + basechar$
                ELSE
                   freqnow = freqnow + 1
                   NewChar$ = MID$(ToCipher, i, 1)
                        dif% = ASC(NewChar$) - ASC(basechar$)
                        IF dif% >= 0 THEN
                           ans$ = ans$ + CHR$(dif%)
                        ELSE
                                ans$ = ans$ + CHR$(256 + dif%)
                        END IF
                END IF
   NEXT i
   KT.ENC.DifCipher$ = ans$
END FUNCTION

8)
Pages: 1 2 3 4 5 6 7 8 9