Posts: 23
Threads: 1
Joined: Jun 2003
hmm, didnt think of that, thanks
This is the end of everything, you are the end of everything." -Slipknot - Everything Ends
"GOD HATES US ALL!!" -Slayer - God Hates Us All
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 22
Threads: 0
Joined: Jun 2003
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]
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 22
Threads: 0
Joined: Jun 2003
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]
Posts: 3,343
Threads: 83
Joined: Mar 2003
I already did a key one... see above. agamemnus hasn't posted a decoding program for it yet.
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 1,956
Threads: 65
Joined: Jun 2003
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.
*****
Posts: 3,343
Threads: 83
Joined: Mar 2003
Oi, my method uses a very long key... what's wrong with it? Assume I don't add those zeroes on each character.
Posts: 1,845
Threads: 44
Joined: Aug 2002
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)