Qbasicnews.com
December 16, 2019, 10:33:53 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Cryptogram!  (Read 7077 times)
Zack
*/-\*
*****
Posts: 3974



WWW
« on: May 26, 2006, 06:03:13 PM »

Code:
GY QSS ZIT YGKXD DTDWTKL ITKT, DQFN QKT ESTCTK TFGXUI ZG YOUXKT ZIOL GXZ. QUQDTDFXL OL HQKZOEXSQKSN UGGR QZ ZIOL LGKZ GY ZIOFU, QFR LG O'D WTZZOFU ZIQZ IT VOSS VOF ZIOL EGDHG. UGGR SXEA ZG QSS, QFR OY NGX QKT ZIOL YQK QSGFU, EGFUKQZL, NGX IQCT OZ!

Reveal what each letter stands for then substitute - the result is a cute little message. If nobody gets it then I'll post the source code that generated it.
Hint: a shortcut is right under your nose.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
TheAdventMaster
Ancient Guru
****
Posts: 671


« Reply #1 on: May 26, 2006, 07:18:34 PM »

Now I'm no genius, but basics of cryptography is to try the simplist methods first.  For anyone who's interested, here you go.  Use UNDO as the input_string to undo something, and ESC to quit:

Turn Write_To_File = true to write your decrypt to file.

NOTE: This does not support switching more than one character in one move.  I'm pretty sure you'd want to use MID for that and I don't use MID.

Code:
Const false = 0, true =  not false

'Dim your Variables Here:
dim counter = 0

dim write_to_file as integer 'If this is true, then it will write the text to a file:
write_to_file = true

dim a as string

dim b(0 to 25) as string

'Put the Crytext into a string:
A = "GY QSS ZIT YGKXD DTDWTKL ITKT, DQFN QKT ESTCTK TFGXUI ZG YOUXKT ZIOL GXZ. QUQDTDFXL OL HQKZOEXSQKSN UGGR QZ ZIOL LGKZ GY ZIOFU, QFR LG O'D WTZZOFU ZIQZ IT VOSS VOF ZIOL EGDHG. UGGR SXEA ZG QSS, QFR OY NGX QKT ZIOL YQK QSGFU, EGFUKQZL, NGX IQCT OZ!"
B(0) = A

dim a_save(0 to len(a)) as integer

'The Variables for the Input and Replace:
Dim Input_String as string
Dim Replace_String as String

do
   
    'Clear the Screen and Print the text:
    cls
    Print A
   
    'Input, the string you want to replace:
    Input "Which letter will you replace? ", Input_String
   
   
    'If the string is UNDO then undo:
        if ucase$(input_string) = "UNDO" then
           
            'If it's legal to do so, go back one step:
            if counter > 0 then
                counter -= 1
            end if
            A = B(counter)
   
    'If the String isn't undo, then add to the changes made:
        else
           
            If ucase$(Input_String) = "ESC" then
                If write_to_file = true then
                    open "Cryptext.txt" for output as #1
                        Print #1, A
                    Close #1
                end if
                end
            end if
           
            counter += 1
           
           
        'What do you want to replace your string with?
            Input "Replace With What? ", Replace_String
           
        'Replace all characters of Input_string with your Replace_String
            for do_text = 0 to len(a) - 1
           
            'If A, character do_text is equivalent to Input_String, replace with ReplaceString:
                if a[do_text] = asc(input_string) then
                    if a_save(do_text) = false then
                        a[do_text] = asc(Replace_string)
                        a_save(do_text) = true
                    end if
                end if
       
            next
           
        end if
       
    'Make the undo_string = A:
        B(counter) = A


If write_to_file = true then
    open "Cryptext.txt" for output as #1
        Print #1, A
    Close #1
end if
   
loop
Logged
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #2 on: May 26, 2006, 07:54:27 PM »

Code:
of all the forum members here, many are clever enough to figure this out.
agamemnus is particularly good at this sort of thing, and so i'm betting
that he will win this compo. good luck to all, and it you are this far
along, congrats, you have it!


 Tongue .... Few minutes in FBIde changing the letters around as they fitted..  :mrgreen:
Logged

Kevin (x.t.r.GRAPHICS)

TheAdventMaster
Ancient Guru
****
Posts: 671


« Reply #3 on: May 26, 2006, 07:55:49 PM »

I was wondering what 3 letter word has two letters that are the same...That would make sense.

How on earth could I have missed the world, "All"?  That's normally the simplist one to figure out... ^_^;;

EDIT: Updated program to know whether you have switched a letter already or not.  No more problems with switching H to I, then I to whatever... Cheesy
Logged
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #4 on: May 26, 2006, 08:03:08 PM »

Quote from: "TheAdventMaster"
I was wondering what 3 letter word has two letters that are the same...That would make sense.

How on earth could I have missed the world, "All"?

I was thinking a-s-s for a bit, but then I saw I hadn't swapped the S's yet...  :shifty:
Logged

Kevin (x.t.r.GRAPHICS)

TheAdventMaster
Ancient Guru
****
Posts: 671


« Reply #5 on: May 26, 2006, 08:05:45 PM »

Quote from: "Rattrapmax6"
I was thinking a-s-s for a bit, but then I saw I hadn't swapped the S's yet...  :shifty:
Well you gave me a good idea:  Updated program to know whether you have switched a letter already or not.  No more problems with switching H to I, then I to whatever... Cheesy

Thnx Tongue

This was a fun challenge.  Make another crypto plz Tongue
Logged
Ralph
Ancient Guru
****
Posts: 544


« Reply #6 on: May 26, 2006, 10:13:12 PM »

My answer:

OF ALL THE FORUM MEMBERS HERE, MANY ARE CLEVER ENOUGH TO FIGURE  
GY QSS ZIT YGKXD   DTDWTKL   ITKT, DQFN QKT ESTCTK TFGXUI ZG YOUXKT

THIS OUT AGAMEMNUS IS  PARTICULARLY    GOOD AT THIS SORT OF THING,
ZIOL GXZ. QUQDTDFXL OL HQKZOEXSQKSN UGGR QZ ZIOL LGKZ GY ZIOFU,

AND SO IM   BETTING THAT HE WILL WIN THIS COMPO. GOOD LUCK TO  ALL,          
QFR LG O'D WTZZOFU ZIQZ IT VOSS VOF ZIOL EGDHG. UGGR SXEA ZG QSS,

AND  IF  YOU ARE THIS  FAR ALONG, CONGRATS, YOU HAVE IT!  
QFR OY NGX QKT ZIOL YQK QSGFU, EGFUKQZL, NGX IQCT OZ!
Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Z!re
*/-\*
*****
Posts: 4599


« Reply #7 on: May 27, 2006, 08:59:08 AM »

Here's a more interessting one:
Code:
e[^_]øp|Mޅ7UWVSLE]0~ VUm
ue[^_]fXMv7 Eu
EUS]@UԋMfUUfEꘉ)lj@19}B<UF1E UL$MfEED$EԉT$ $D$ 6EEL\EH@e[^_]É|$1ɍdL$D$ \$@

Enjoy!



...
Logged
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #8 on: May 27, 2006, 11:17:32 PM »

@Z!re: you sure there aren't undisplayed characters in there? There would be if you copied it directly from some sort of bitwise encryption.

Anywho, good job all! Here's the code that generated it - notice how the character correspond. :wink:
Code:
dim as string kb,ol,phrase,temp,c_phrase
dim as integer offset
kb="QWERTYUIOPASDFGHJKLZXCVBNM"
ol="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
phrase="OF ALL THE FORUM MEMBERS HERE, MANY ARE CLEVER ENOUGH TO FIGURE THIS OUT. " + _
        "AGAMEMNUS IS PARTICULARLY GOOD AT THIS SORT OF THING, AND SO I'M BETTING " + _
        "THAT HE WILL WIN THIS COMPO. GOOD LUCK TO ALL, AND IF YOU ARE THIS FAR ALONG, " + _
        "CONGRATS, YOU HAVE IT!"
apos=asc("A")
zpos=asc("Z")
for i=1 to len(phrase)
    temp=mid$(phrase,i,1)
    if asc(temp)>=apos and asc(temp)<=zpos then
        offset=asc(temp)-apos+1
        c_phrase+=mid$(kb,offset,1)
    else
        c_phrase+=temp
    end if
next
print phrase
print c_phrase
sleep
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Z!re
*/-\*
*****
Posts: 4599


« Reply #9 on: May 28, 2006, 11:35:52 AM »

Quote from: "Zack"
@Z!re: you sure there aren't undisplayed characters in there? There would be if you copied it directly from some sort of bitwise encryption.
I'm sure.
Well, provided you have a ISO standard charset enabled on your computer, which you should have.
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #10 on: May 28, 2006, 03:14:29 PM »

Interesting. I made something that compares English letter frequencies and it has about half the letters correct. It's possible to make it more correct by adding in letter frequencies for common words, etc. I don't want to post it yet though, 'cause half correct letters still look like mumbo jumbo. Maybe when/if I put in the 2-letter word frequencies...
Logged

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.
Skyler
Ancient Guru
****
Posts: 564



« Reply #11 on: July 28, 2006, 11:48:22 AM »

I found a cryptogram solver which generates a random key, compares the frequencies to plaintext, and then modifies the random key until it gets the best match. Then it generates another random key, and so on, until the plaintext is mostly revealed, at which time you halt the program and copy the answer. Basically a genetic algorithm.
Logged

In the beginning, there is darkness the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!