+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def b2_encipher(message, keyword):\n",
+ " \"\"\"Vigenere encipher\n",
+ "\n",
+ " >>> vigenere_encipher('hello', 'abc')\n",
+ " 'hfnlp'\n",
+ " \"\"\"\n",
+ " shifts = [pos(l) for l in sanitise(keyword)]\n",
+ " pairs = zip(message, cycle(shifts))\n",
+ " return cat([unpos(k - pos(l)) for l, k in pairs])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'sevsvrusyrrxfayyxuteemazudmpjmmwr'"
+ ]
+ },
+ "execution_count": 22,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "b2_encipher('inhisjournaldatedtheidesofoctober', 'arcanaimperii')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "b2_decipher = b2_encipher"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'inhisjournaldatedtheidesofoctober'"
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "b2_decipher('sevsvrusyrrxfayyxuteemazudmpjmmwr', 'arcanaimperii')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []