Coders Packet

Probable Key Length Finder and Decryption using C

By Abhiram eerla

  • Probable Key Length Finder and Decryption.rtf
  • Calculates the frequencies of characters in the cipher text at a given interval and Decrypts the cipher text using the given key.

     

    code output:keyenth

     

     

     

    sample code:

     

    code sample codeabhi1

     

     

    The first function, calculateFrequencies(), calculates the frequencies of characters in the given text at the given interval. The interval is the number of characters to skip between each character when calculating the frequencies. For example, if the interval is 2, then the function will calculate the frequencies of characters at every other character in the text.

    The second function, findProbableKeyLength(), finds the probable key length of the given cipher text. The function does this by first calculating the sum of squares of the frequencies of characters in the cipher text at different intervals. The function then chooses the interval with the sum of squares closest to the target sum of squares for English text (0.065). The function returns the chosen interval as the probable key length.

    The third function, decryptText(), decrypts the given cipher text using the given key. The function does this by iterating over the cipher text and decrypting each character using the corresponding character in the key. The function wraps around the key if necessary.

    The main() function first calls the findProbableKeyLength() function to find the probable key length of the given cipher text. The function then prints the probable key length to the console. The function then calls the decryptText() function to decrypt the cipher text using the probable key. The function then prints the decrypted text to the console.

    Here is an example of the output of the program:

    Probable Key Length: 5
    
    Decrypted Text:
    This is a simple message encrypted using a Vigenere cipher.

    Download Complete Code

    Comments

    No comments yet

    Download Packet

    Reviews Report

    Submitted by Abhiram eerla (Abhirameerla)

    Download packets of source code on Coders Packet