Here we define an alphabet, encode a message in it, and define the Vigenere Cryptosystem in Sage. Note that we need to designate the keylength (here, 4), when we define the cryptosystem.
Now we can create a ciphertext out of our plaintext and a key of length 4. Here we use as our key the word BONK:
Now we can decipher using the same key:
Here’s a sandbox for you to play with:
Encryption
Decryption