BF: a pure Beaufort cipher.
BF uses a pure Beaufort algorithm to encrypt text in the visible range of ASCII characters. High-bit characters and control characters below
are left as-is. The output is exactly the same size as the input, and all are 7-bit characters. A classic Beaufort crypt is presented as a 'tabula recta' of 26 alphabets, rotating one character per line. The encryption process requires a key-text and message-text of the same size; take each character in order, find its place in the top row of the table, trace the column down to the corresponding key character, and output the 'encrypted' letter in the first column. Simple enough for an agent in hostile territory to do in a hurry. If the key is well-protected, it's very secure against a manual attack, although cryptologists say it's easily broken by sufficient compute power. If you don't happen to have an alphabet-grid handy, there is an easy mathematical algorithm for doing encryption/decryption: subtract the text-letters from the key-letters to get the encrypted letters. Decrypt in exactly the same way: subtract your message from the key. So, what does that mean, 'subtract the message from the key'? Print your key, triple-spaced if it's multiple lines. Under each letter of the key, write each letter of the message text. If you run out of key letters, start repeating the key from the beginning until you reach the length of the message, but note: if the key is short by very much, the repetition will cause patterns to appear, weakening the value of the cipher. Using the alphabetic ordinal values of the letters, subtract each text value from its corresponding key value. If you're doing this manually, you can skip all the spacing and punctuation, and reduce the character set to uppercase letters to keep the arithmetic in the 1-26 range. Subtracting Q (17) from H (8), e.g., will go negative; add 26 to bring it back in range. Convert this ordinal value back to its letter value, and that is the encrypted letter. The range of visible ASCII text is 32-126, i.e., 95 characters. If a computer is doing the work (or even a calculator), it's easy to do the arithmetic over the whole range of uppercase, lowercase, numbers and punctuation. After subtracting the message character from its key character (using ASCII values, not ordinals), add 95 to bring it into the 32-126 range. Beaufort is a well-known algorithm, so serious cryptanalysis will easily decode whatever you hide with this routine. It's a learning exercise. Feel free to fiddle with it or salt the key to make it stronger.
!! no key provided. !! nothing to encrypt.