Python Forum
Python function that uses a word as the encryption key, rather than an integer
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python function that uses a word as the encryption key, rather than an integer
#1
I am confused on what to add as my encryption function via the Vigenere cipher... I am more familiar with the Caesar method so I am drawing a complete blank here. Please help with any suggestions.

import alphabet_positon

letter = input("Enter a letter: ")

def alphabet_position(letter):
    alphabet_pos = {'A':0, 'a':0, 'B':1, 'b':1, 'C':2, 'c':2, 'D':3,
                    'd':3, 'E':4, 'e':4, 'F':5, 'f':5, 'G':6, 'g':6,
                    'H':7, 'h':7, 'I':8, 'i':8, 'J':9, 'j':9, 'K':10,
                    'k':10, 'L':11, 'l':11, 'M':12, 'm':12, 'N': 13,
                    'n':13, 'O':14, 'o':14, 'P':15, 'p':15, 'Q':16,
                    'q':16, 'R':17, 'r':17, 'S':18, 's':18, 'T':19,
                    't':19, 'U':20, 'u':20, 'V':21, 'v':21, 'W':22,
                    'w':22, 'X':23, 'x':23, 'Y':24, 'y':24, 'Z':25, 'z':25 }
    pos = alphabet_pos[letter]
    return pos 

def rotate(letter, rot):
shift = 97 if letter.islower() else 65
return chr((ord(letter) + rot - shift) % 26 + shift)

letter = input('Enter a letter: ')
rot = int(input('Enter a number: '))
print(rotate(letter, rot))

# add encrypt function 
Reply


Messages In This Thread
Python function that uses a word as the encryption key, rather than an integer - by wak_stephanie - Aug-30-2018, 04:57 PM
Encrypting the Vigenere cipher - by wak_stephanie - Aug-31-2018, 03:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  encryption and decryption with python ibrahim 1 303 May-16-2020, 03:14 PM
Last Post: Larz60+
  Python Speech recognition, word by word AceScottie 6 8,795 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  write an integer to file using a function xvkxvo 4 623 Dec-10-2019, 11:27 PM
Last Post: xvkxvo
  File encryption itzik 5 453 Nov-05-2019, 12:29 PM
Last Post: Gribouillis
  print a word after specific word search evilcode1 8 734 Oct-22-2019, 08:08 AM
Last Post: newbieAuggie2019
  A function for correctly using "a/an" before a word Exsul1 2 598 Oct-07-2019, 07:51 PM
Last Post: newbieAuggie2019
  Vernam encryption method for files JohnCTX 1 461 Sep-18-2019, 04:31 PM
Last Post: JohnCTX
  python cache for small integer Uchikago 1 757 Jun-27-2019, 05:32 PM
Last Post: ichabod801
  Regarding encryption and decryption naressh1994 1 675 Jan-25-2019, 07:26 AM
Last Post: buran
  AES encryption - does not match between arduino and python 3 crypto guillaume55 0 1,877 Sep-23-2018, 11:14 AM
Last Post: guillaume55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020