I think I've written the bit array soup for the Encrypt() and Decrypt() functions.