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 4007350
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:37:19+00:00 2026-05-20T08:37:19+00:00

Hey, I have been working on this for a while, and I can remebr

  • 0

Hey, I have been working on this for a while, and I can remebr my brother stepped me through this very same alogorithm.

Basicly, it just adds the ascii values of both the characters from the key, and the phrase.

I can encrypt it with this:

def encrypt(key, string):
    encoded = ''
    for i in range(len(string)):
        key_c = ord(key[i % len(key)])
        string_c = ord(string[i % len(string)])
        encoded += chr((key_c + string_c) % 127)
    return encoded

But I can’t seem to remember what we did as far as decrypting. Its difficult to revers a mod 😛
Any ideas?

  • 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-05-20T08:37:20+00:00Added an answer on May 20, 2026 at 8:37 am

    That’s simple, let’s see how it works. First of all, the encrypted message is obtained by subtracting the key.

    enc = msg + key (mod 127)
    

    How can we obtain the original message? That’s easy, subtract the key in both sides

    enc - key = msg + key - key (mod 127)
    

    And here we get:

    enc - key = msg (mod 127)
    

    For more details, please refer to Modular arithmetic, I think it should belong one of group/field/ring. I’m not an expert in math, for further reading, you should check out Number theory. Here is the refined code:

    def encrypt(key, msg):
        encryped = []
        for i, c in enumerate(msg):
            key_c = ord(key[i % len(key)])
            msg_c = ord(c)
            encryped.append(chr((msg_c + key_c) % 127))
        return ''.join(encryped)
    
    def decrypt(key, encryped):
        msg = []
        for i, c in enumerate(encryped):
            key_c = ord(key[i % len(key)])
            enc_c = ord(c)
            msg.append(chr((enc_c - key_c) % 127))
        return ''.join(msg)
    
    if __name__ == '__main__':
        key = 'This_is_my_awsome_secret_key'
        msg = 'Hello world'
        encrypted = encrypt(key, msg)
        decrypted = decrypt(key, encrypted)
        
        print 'Message:', repr(msg)
        print 'Key:', repr(key)
        print 'Encrypted:', repr(encrypted)
        print 'Decrypted:', repr(decrypted)
    

    Output

    Message: 'Hello world'
    Key: 'This_is_my_awsome_secret_key'
    Encrypted: '\x1dNV`O\nkO`fD'
    Decrypted: 'Hello world'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, i've been working on this small project in XNA the goal is
Hey all, i have been trying for a few minutes on this problem and
Hey guys, ive been working on this drop down for wayyy to long now.
Hey folks, I have to apologize for my inexperience here, I've been working on
Hey all, have been working on designing a new database for work. They have
Hey I am very new to Web Programming. I have been learning PHP from
hey ive been working with GLM and i have been noticing that im not
Hey peoples, I've been studying Java for a couple of weeks, and have decided
Hey i have this div that shows as a popup: <div class=popup> </div> Then
Hey. I have an object that has a string property called BackgroundColor. This string

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.