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

  • Home
  • SEARCH
  • 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 7731839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:34:51+00:00 2026-06-01T06:34:51+00:00

I wrote a little program to do generalized caesar ciphers. I can’t figure out

  • 0

I wrote a little program to do generalized caesar ciphers. I can’t figure out why my brute force function for decrypting isn’t working. All I’m trying to do is try every possible combination of multiplier and offset less than 26. Also, if anyone can suggest a better approach for the “tryallcombinations” function, that would be appreciated.

import Data.Char

caesarencipher::Int->Int->String->String
caesarencipher r s p = map chr $ map encipher plaintext
    where
        plaintext = map (\x->(ord x) - 97) p
        encipher p =  (mod (r*p + s) 26) + 97

caesardecipher::Int->Int->String->String
caesardecipher r s c = map chr $ map decipher ciphertext
    where
        ciphertext = map (\x->(ord x) - 97) c
        inverser x | mod (r * x) 26 == 1 = x
                   | otherwise = inverser (x + 1)
        decipher c = (mod ((inverser 1) * (c - s)) 26) + 97

tryallcombinations::String->[String]
tryallcombinations ciphertext = map (\x->x ciphertext) possibilities
    where
        rs = map caesardecipher [0..25]
        possibilities = concat $ map (\x-> map x [0..25]) rs
  • 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-01T06:34:53+00:00Added an answer on June 1, 2026 at 6:34 am

    26 is not a prime, so not all numbers have a modular inverse mod 26. That means that inverser sometimes never returns but recurses forever.

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

Sidebar

Related Questions

I'm a little bit confused about simple program which I wrote, can You please
I wrote a little program that solves 49151 sudoku's within an hour for an
I've been playing with Python for a while and wrote a little program to
I wrote a nice little program. At some point, it is required to load
I wrote a little Haskell program to find the area of a triangle, primarily
I am a little curious why the program I wrote on Xcode with a
My 15 year old little brother is starting out programming, and he wrote a
I ported a little Haskell program I wrote from Mac to Windows. It's a
I have this simple little batch file program that I wrote but it fails
I wrote a little program to draw a pattern a cycle through different color

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.