Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-142

Vigenere Encrypt

Problem

Encrypt uppercase text with the Vigenere cipher: shift each letter by the corresponding key letter, repeating the key, with all arithmetic modulo 26. Return the uppercase ciphertext, which has the same length as the text.

Hint

A key of A leaves the text unchanged.

Test cases

case 1
in: ["HELLO","KEY"]
expected: "RIJVS"
case 2
in: ["ABC","AAA"]
expected: "ABC"
case 3
in: ["XYZ","BCD"]
expected: "YAC"
case 4
in: ["ATTACKATDAWN","LEMON"]
expected: "LXFOPVEFRNHR"
Starter codePython
def vigenere_encrypt(text, key):
    # Your code here
    pass

4 test cases · run your code against them in the editor