Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:05:39+00:00 2026-06-11T09:05:39+00:00

I have been working on the problem sets at Project Euler for some time

  • 0

I have been working on the problem sets at Project Euler for some time and have enjoyed the challenges presented. I am currently on Problem 59 which involves the process of encryption and decryption.

The problem is, by any reasonable standard, a very simple decryption problem.

  • I have been told that the encryption key consists of 3 lowercase letters.
  • I have been given a description of the encryption/decryption process.
  • I have been given an encrypted text file which contains only encrypted common English words

I fully understand the process of importing the data, cycling through all possible keys, and attempting to decrypt the file data with each possible key. My trouble is, after a decryption attempt with one of the keys, how can I tell if that key was the correct decryption key? As far as the computer is concerned, every decryption key just converts the data from one value to another. The meaning of that value is purely subjective/interpreted. How can I tell if a decryption key has decrypted the data into something meaningful (ie. common English words)

Here is the code I have so far (C#):

    static void Main(string[] args)
    {
        /* Get the data from the file and convert to byte array*/
        StreamReader inData = new StreamReader(@"C:\Users\thantos\Desktop\cipher1.txt");
        string[] strData = inData.ReadLine().Split(new char[] {','});
        byte[]  fileData = new byte[strData.Length];
        foreach (string x in strData) { byte.Parse(x); }

        /* for each three character lowercase password */
        for (uint i = 0; i < 26; i++) {
            for (uint j = 0; j < 26; j++){
                for (uint k = 0; k < 26; k++) {
                    /* create a key */
                    byte[] key = new byte[3];
                    key[0] = (byte)(i + 97);
                    key[1] = (byte)(j + 97);
                    key[2] = (byte)(k + 97);

                    /* create temp copy of data */
                    byte[] dataCopy = new byte[fileData.Length];
                    fileData.CopyTo(dataCopy, 0);

                    /* decrypt using key */
                    for (uint l = 0; l < dataCopy.Length; l++) { 
                        dataCopy[l] = (byte)(dataCopy[l] ^ key[l%key.Length]);
                    }

                    /* cannot figure out how to check 
                     * if data is meaningfully decrypted
                     */
                    bool dataIsMeaningful = isMeaningful(dataCopy);

                    if(dataIsMeaningful) {
                      /* do stuff with data if correct 
                       * decryption key was found 
                       */
                    }
                }
            }
        }
    }

I have tried this method for isMeaningful():

public static isMeaningful(byte[] inData) {
  bool isGood = true;
    for (uint i = 0; good && i < inData.Length; i++) {
      isGood &= (char.IsLower((char)inData[i]));;
    }
   return isGood;
}

But it returns true for all 17576 possible keys.

How can I determine if the decryption key has decrypted the file data into meaningful data? I’m not looking for solution code or the answer to the Project Euler problem, I am looking for an explanation of how to check that your decryption attempt was successful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:05:41+00:00Added an answer on June 11, 2026 at 9:05 am

    Try different keys and score them against the letter frequency of normal English: space, followed by E, T, A, O, I, N, S, H, R, D, L, U. Pick the highest scoring keys first for a trial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on this problem for quite some time and can't figure
I'm working on http://lobounce.com.s138810.gridserver.com/ and have been having some problems with the slider which
This is one of the problem i have been working from a long time.This
I'm have been working on solving Project Euler #14 for a while now in
I have been working on a coding problem for some pages I inherited where
I have been working on this problem for 2 days now and it's an
I have been working on this problem for a while now. I am trying
I have been working on the following problem from this book . A certain
I have been working for a couple of days on a problem with my
I've been working on this problem for a few hours and have used many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.