CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Deploying Windows Server 2008 with System Center
  • Remote Desktop Protocol Performance Improvements in Windows Server 2008 R2 and Windows 7
  • The Microsoft Dynamics CRM Security Model
  • SQL Server Modeling Services with Microsoft Visual Studio 2010 Beta 2

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ (Non Visual C++ Issues)
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C++ (Non Visual C++ Issues) Ask or answer C and C++ questions not related to Visual C++. This includes Console programming, Linux programming, or general ANSI C++.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old November 15th, 2006, 10:02 PM
    herrkutt herrkutt is offline
    Junior Member
     
    Join Date: Nov 2006
    Posts: 3
    herrkutt is an unknown quantity at this point (<10)
    Running Key Cipher

    Running Key Cipher:

    http://en.wikipedia.org/wiki/Running_key_cipher

    Text: "SEE SPOT RUN"
    Key: "SPOT RUN SEE"
    Crypt: "H76tsDFD@G<5"

    What I did here was add the ASCII values of the top and bottom mod 26 and add 32, then convert back to letters.

    Anyone have any ideas on how this could be decrypted given a much larger encrypted piece of text (38,000 Characters)?
    I was thinking using some sort of patter or frequence analysis but im stuck.
    Unfortunately I have to write this in C so any input would be greatly appreciated, thanks.
    Reply With Quote
      #2    
    Old November 16th, 2006, 07:05 AM
    SuperKoko's Avatar
    SuperKoko SuperKoko is offline
    Elite Member
    Power Poster
     
    Join Date: Feb 2005
    Location: Normandy in France
    Posts: 4,590
    SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+)
    Re: Running Key Cipher

    Quote:
    Originally Posted by herrkutt
    Running Key Cipher:

    http://en.wikipedia.org/wiki/Running_key_cipher

    Text: "SEE SPOT RUN"
    Key: "SPOT RUN SEE"
    Crypt: "H76tsDFD@G<5"

    What I did here was add the ASCII values of the top and bottom mod 26 and add 32, then convert back to letters.

    Anyone have any ideas on how this could be decrypted given a much larger encrypted piece of text (38,000 Characters)?
    I was thinking using some sort of patter or frequence analysis but im stuck.
    Unfortunately I have to write this in C so any input would be greatly appreciated, thanks.
    Ascii code for S is 83
    (83+83)%26+32 == 42
    42 is (apart from being the ultimate answer to the question about the life, universe and everything) the ASCII code for *

    * has not the same ASCII code than H, so I deduce from it that you've not given us the exact algorithm you used.
    Moreover, there is an irreversible loss of data when you use %26
    If you want to encode any ASCII character, you should compute modulo 128
    If you want to encode any extended ASCII character, you should compute modulo 256
    __________________
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!
    Reply With Quote
      #3    
    Old November 16th, 2006, 08:25 AM
    herrkutt herrkutt is offline
    Junior Member
     
    Join Date: Nov 2006
    Posts: 3
    herrkutt is an unknown quantity at this point (<10)
    Re: Running Key Cipher

    Yeah I just realized I did
    ((83+83)-122)+32

    122 since I have been given that no { } | ~ ad DEL will be used.

    Either way it doesnt matter about the logic of my little example that I just made up.
    The main point I was trying to get across is that an "E" can have 2 different values in the encrypted text.
    Reply With Quote
      #4    
    Old November 16th, 2006, 12:49 PM
    SuperKoko's Avatar
    SuperKoko SuperKoko is offline
    Elite Member
    Power Poster
     
    Join Date: Feb 2005
    Location: Normandy in France
    Posts: 4,590
    SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+) SuperKoko has a brilliant future (2000+)
    Re: Running Key Cipher

    Quote:
    Originally Posted by herrkutt

    The main point I was trying to get across is that an "E" can have 2 different values in the encrypted text.
    I understand what you mean.

    In order to decrypt text, you must have the key (that is, you must know the encrypted text as well as the "SPOT RUN SEE" string).

    Simply, apply the inverse operation:

    instead of (uncoded_char+key_char)-122+32, you should apply coded_char-32+122-key_char

    However, your encryption algorithm is weaker than the (weak) running key cipher algorithm.
    Because you don't use any modulo operation.

    So, for example, if the encoded contain 'Z' (90), anybody can know that the only possible value for the key & original text is 'Z' (90) for both.

    If you want to make this algo work, you must choose of a range of values that you accept.
    For example [32, 96)
    Then, compute (uncoded_char-32 + key_char-32)%(96-32)+32 in order to cypher the char, or (coded_char-32 - (key_char-32))%(96-32)+32 in order to decypher the char.
    __________________
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!
    Reply With Quote
      #5    
    Old November 16th, 2006, 03:22 PM
    herrkutt herrkutt is offline
    Junior Member
     
    Join Date: Nov 2006
    Posts: 3
    herrkutt is an unknown quantity at this point (<10)
    Re: Running Key Cipher

    Ok alright, I understand thanks man, yet the only problem is I do not know the Key I only have the Encrypted text, I have to find out the key first :-S
    Thats the trick, and what Im stuck on.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ (Non Visual C++ Issues)


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:57 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.