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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:32:17+00:00 2026-06-06T03:32:17+00:00

I would like to build a cypher with python which decoding text by repeatedly

  • 0

I would like to build a cypher with python which decoding text by repeatedly travel through the numbers of the shifter from left to right and then from right to left and shift the letter in the alphabet by the corresponding number.

Example:

  • shifter: 123
  • text: i like python
  • process: i+1=j, space, l+2=n, i+3=l, k+3=n, e+2=g, space, p+1=q, y+1=z, t+2=v, h+3=j, o+3=q, n+2=p
  • result: j nlng qzvjqp

The code so far:

import string

numbers = ""

x = 3

while x < 10000:
    numbers = numbers + str(x)
    x += 1

shift = 221

#string.ascii_lowercase
letters = string.ascii_letters + string.punctuation + numbers
text = (raw_input("Please enter text"))

encoded = ''
for letter in text:
    if letter == ' ':
        encoded = encoded + ' '
    else:
        x = letters.index(letter) + shift
        encoded = encoded + letters[x]

print encoded

It uses so far a basic coding method. I would love to know how is it possible to implement the above described encoding system in the code.

  • 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-06T03:32:19+00:00Added an answer on June 6, 2026 at 3:32 am

    Here is your version optimized (and working):

    import string
    
    shift = 221
    
    letters = string.ascii_letters + string.punctuation + string.digits
    text = raw_input("Please enter text\n")
    
    e = ''.join(letters[letters.index(l) + shift % len(letters)]
                if letters.index(l) is not None else ' ' for l in text)
    print e
    

    Edit The part with numbers was really wrong, because it added duplicate letters to your encoding sequence. This means that an encoded text cannot be decoded uniquely.

    Edit2: If you want secure en/decryption, you need a modern algorithm like AES. If you want it implement on your own or understand the code, RC4 is a simple (but still secure if used correctly) alternative.

    Edit3: Here is Vigenere in an optimized version:

    from itertools import cycle, izip
    from operator import add, sub
    from string import printable as alphabet
    
    def vigenere(text, key, mode='encode'):
        alen = len(alphabet)
        key = cycle(key + key[-2:0:-1])
        op = add if mode == 'encode' else sub
        return ''.join(alphabet[op(alphabet.index(c),
                                   alphabet.index(k)) % alen]
                       for c, k in izip(text, key))
    
    c = vigenere('attack at dawn', 'secret', mode='encode')
    print c  # CHFBqN8BF8FoIO
    print vigenere(c, 'secret', mode='decode')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to build a DLL (which should be accessed from a web
I would like to build an adaptor object which behaves like a (text) file
I would like to build some code which calls some code on loadup of
I would like to build a cross-platform GUI application in Python that displays PostScript
I would like to build a general matrix module, which includes such general operations
I would like to build an iOS whitelabel application which should be customizable to
I would like to build Nuget package for my add-on which will be used
I would like to build a mobile app, brewed from nothing more but html/css
I would like to build a version of Perl that is separate from the
I would like to build a navigation which works and looks like on the

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.