The script above is a basic implementation of the Vigenère cipher: a polyalphabetic substitution cipher originally described by Giovan Battista Bellaso in 1553.
A critical factor in the cipher's level of security is the length of the key. Long messages with short keys are vulnerable to being cracked by a method devised by Charles Babbage in 1854. For situations where security is important, it is sensible to use a much stronger cipher, such as AES. The Vigenere Cipher is mostly useful as a means of learning about cryptography.
Back to a sibilant intake of breath