Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Let's have an encryption CHALLENGE!
#5
took some work *whew*

Code:
'WE "(Whitetiger Encryption)" decrypter:
'http://www.geocities.com/pisforpi/flyingsoft

CLS
RANDOMIZE TIMER
option1% = 1

cipherkey& = 1 + INT(RND * 1000)

IF option1% = 1 THEN
word$ = "Agamemnus >> Hello, whitetiger's smiley. How does it feel to be the smartest avatar in the world?"
word$ = word$ + "whitetiger's smiley >> Pretty good, actually. How does it feel to be talking to a smiley, Agamemnus?"
word$ = word$ + "Agamemnus >> Pretty good, actually."
word$ = word$ + "Agamemnus >> *clears voice*: 'The quick brown fox jumped over the lazy dog(s)', I think."

ELSE

'Nonsense below.

word$ = word$ + "That can I;"
word$ = word$ + "At least, the whisper goes so. Our last king,"
word$ = word$ + "Whose image even but now appear'd to us,"
word$ = word$ + "Was, as you know, by Fortinbras of Norway,"
word$ = word$ + "Thereto prick'd on by a most emulate pride,"
word$ = word$ + "Dared to the combat; in which our valiant Hamlet--"
word$ = word$ + "For so this side of our known world esteem'd him--"
word$ = word$ + "Did slay this Fortinbras; who by a seal'd compact,"
word$ = word$ + "Well ratified by law and heraldry,"
word$ = word$ + "Did forfeit, with his life, all those his lands"
word$ = word$ + "Which he stood seized of, to the conqueror:"
word$ = word$ + "Against the which, a moiety competent"
word$ = word$ + "Was gaged by our king; which had return'd"
word$ = word$ + "To the inheritance of Fortinbras,"
word$ = word$ + "Had he been vanquisher; as, by the same covenant,"
word$ = word$ + "And carriage of the article design'd,"
word$ = word$ + "His fell to Hamlet. Now, sir, young Fortinbras,"
word$ = word$ + "Of unimproved mettle hot and full,"
word$ = word$ + "Hath in the skirts of Norway here and there"
word$ = word$ + "Shark'd up a list of lawless resolutes,"
word$ = word$ + "For food and diet, to some enterprise"
word$ = word$ + "That hath a stomach in't; which is no other--"
word$ = word$ + "As it doth well appear unto our state--"
word$ = word$ + "But to recover of us, by strong hand"
word$ = word$ + "And terms compulsatory, those foresaid lands"
word$ = word$ + "So by his father lost: and this, I take it,"
word$ = word$ + "Is the main motive of our preparations,"
word$ = word$ + "The source of this our watch and the chief head"
word$ = word$ + "Of this post-haste and romage in the land."
END IF

word$ = UCASE$(word$)
FOR i% = 1 TO LEN(word$)
temp% = ASC(MID$(word$, i%, 1))
IF temp% < 65 THEN GOTO contfor1
IF temp% > 90 THEN GOTO contfor1
word.temp$ = word.temp$ + CHR$(temp%)
contfor1:
NEXT i%

word$ = word.temp$
len.ciphertext% = LEN(word$)
DIM SHARED ciphertext&(1 TO len.ciphertext%)
FOR i& = 1 TO len.ciphertext%
temp& = ASC(MID$(word$, i&, 1))
ciphertext&(i&) = cipherkey& * i& * 2& * temp&
NEXT i&

PRINT "Secret key:"; cipherkey&
cipherkey& = 0
DIM SHARED probability(1 TO 26) AS INTEGER
probability(1) = 820
probability(2) = 150
probability(3) = 280
probability(4) = 430
probability(5) = 1270
probability(6) = 220
probability(7) = 200
probability(8) = 610
probability(9) = 700
probability(10) = 20
probability(11) = 80
probability(12) = 400
probability(13) = 240
probability(14) = 680
probability(15) = 750
probability(16) = 190
probability(17) = 10
probability(18) = 600
probability(19) = 630
probability(20) = 910
probability(21) = 280
probability(22) = 100
probability(23) = 230
probability(24) = 10
probability(25) = 200
probability(26) = 10

DIM SHARED letter.num&(1 TO 26)
DIM SHARED letter.freq#(1 TO 26)
DIM SHARED letter.is&(1 TO 26)

DIM SHARED plaintext%(1 TO len.ciphertext%)
DIM SHARED plaintext.string$

'get probabilities of each number that appeared.
j% = 0
FOR i% = 1 TO len.ciphertext%
cur.num& = ciphertext&(i%) / (i% * 2)

FOR i2% = 1 TO j%
IF cur.num& = letter.num&(i2%) THEN
letter.freq#(i2%) = letter.freq#(i2%) + 1
GOTO contfor2
END IF
NEXT i2%

j% = j% + 1
letter.num&(j%) = cur.num&
letter.freq#(j%) = 1
contfor2:
NEXT i%

'scale the probabilities..
FOR i% = 1 TO j%
tot.freq% = tot.freq% + letter.freq#(i%)
NEXT i%
FOR i% = 1 TO j%
letter.freq#(i%) = 10000 * letter.freq#(i%) / tot.freq%
NEXT i%

'match up the probabilities.
FOR k% = 26 TO 1 STEP -1'26
min.least.diff% = 20000
FOR i% = 1 TO 26
least.diff% = ABS(letter.freq#(i%) - probability(k%))
IF least.diff% <= min.least.diff% THEN
min.least.diff% = least.diff%
most.likely.num& = letter.num&(i%)
END IF
NEXT i%
letter.is&(k%) = most.likely.num&
NEXT k%

'get the key!
FOR k% = 1 TO 26
FOR i% = 1 TO len.ciphertext%
IF letter.is&(k%) = ciphertext&(i%) / (i% * 2) THEN
temp# = ciphertext&(i%) / i%
temp# = temp# / k%
temp# = temp# / 26
temp# = temp# / len.ciphertext%
avg.num# = avg.num# + temp#
END IF
NEXT i%
NEXT k%

cipherkey& = avg.num#
redo1:

'match up the letters..
FOR i% = 1 TO len.ciphertext%
temp# = ciphertext&(i%) / 2
temp# = temp# / i%
temp# = temp# / cipherkey&

'without these corrections, it would be inaccurate..
IF temp# > 90 THEN cipherkey& = cipherkey& + 1: GOTO redo1
IF temp# < 65 THEN cipherkey& = cipherkey& - 1: GOTO redo1
plaintext%(i%) = temp#
NEXT i%

PRINT "Program found this key:"; cipherkey&
PRINT

'convert array to string
FOR i% = 1 TO len.ciphertext%
plaintext.string$ = plaintext.string$ + CHR$(plaintext%(i%))
NEXT i%

PRINT plaintext.string$
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.
Reply


Messages In This Thread
Let's have an encryption CHALLENGE! - by relsoft - 06-11-2003, 08:16 AM
here it is - by Agamemnus - 06-11-2003, 08:34 AM
Let's have an encryption CHALLENGE! - by oracle - 06-11-2003, 12:46 PM
Let's have an encryption CHALLENGE! - by Neo - 06-11-2003, 03:02 PM
BASIC encryption - by Mango - 06-11-2003, 07:49 PM
Let's have an encryption CHALLENGE! - by oracle - 06-12-2003, 01:35 AM
key update - by Mango - 06-12-2003, 04:34 AM
Let's have an encryption CHALLENGE! - by oracle - 06-12-2003, 05:36 AM
My prog - by Meg - 06-12-2003, 04:50 PM
Let's have an encryption CHALLENGE! - by Mango - 06-12-2003, 06:39 PM
Let's have an encryption CHALLENGE! - by oracle - 06-16-2003, 01:38 AM
Let's have an encryption CHALLENGE! - by oracle - 06-16-2003, 01:23 PM
Let's have an encryption CHALLENGE! - by Neo - 06-16-2003, 02:53 PM
unknown, - by Agamemnus - 06-17-2003, 04:03 AM
. - by Meg - 06-18-2003, 10:37 AM
hmmm - by Agamemnus - 06-20-2003, 01:42 AM
Let's have an encryption CHALLENGE! - by oracle - 06-20-2003, 02:41 AM
Let's have an encryption CHALLENGE! - by barok - 06-20-2003, 05:28 AM
Let's have an encryption CHALLENGE! - by oracle - 06-20-2003, 09:34 AM
Let's have an encryption CHALLENGE! - by barok - 06-20-2003, 07:26 PM
Let's have an encryption CHALLENGE! - by oracle - 06-21-2003, 05:04 AM
i'll announce the winners in.... - by Agamemnus - 06-27-2003, 01:44 AM
Let's have an encryption CHALLENGE! - by oracle - 06-27-2003, 11:04 AM
Let's have an encryption CHALLENGE! - by oracle - 07-04-2003, 07:58 AM
well, - by Agamemnus - 07-09-2003, 05:10 AM
Let's have an encryption CHALLENGE! - by Blitz - 07-22-2003, 07:54 AM
Let's have an encryption CHALLENGE! - by na_th_an - 07-22-2003, 01:12 PM
Let's have an encryption CHALLENGE! - by Mango - 07-22-2003, 06:09 PM
Let's have an encryption CHALLENGE! - by Mango - 07-22-2003, 10:16 PM
Let's have an encryption CHALLENGE! - by oracle - 07-23-2003, 01:56 AM
Let's have an encryption CHALLENGE! - by Blitz - 07-23-2003, 03:30 AM
Let's have an encryption CHALLENGE! - by Blitz - 07-23-2003, 03:39 AM
Let's have an encryption CHALLENGE! - by oracle - 07-23-2003, 08:20 AM
Let's have an encryption CHALLENGE! - by Blitz - 07-23-2003, 10:20 AM
um. - by Meg - 07-23-2003, 11:20 AM
aga - by Meg - 07-24-2003, 02:39 AM
Let's have an encryption CHALLENGE! - by Blitz - 07-24-2003, 03:25 AM
yeah it prolly does - by Meg - 07-24-2003, 04:51 AM
well - by Meg - 07-24-2003, 06:32 AM
Let's have an encryption CHALLENGE! - by Phydaux - 07-24-2003, 06:23 PM
Let's have an encryption CHALLENGE! - by Blitz - 07-24-2003, 08:43 PM
Let's have an encryption CHALLENGE! - by Phydaux - 07-24-2003, 09:54 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)