X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=Untitled.ipynb;fp=Untitled.ipynb;h=0000000000000000000000000000000000000000;hb=e670d7e12005cd73385f6c6251174a911ccc018b;hp=023ad1180d381a33dd19e1c351555557ef524457;hpb=6a78463ff5c7d2268c8262e8b3dd196945085142;p=cipher-tools.git diff --git a/Untitled.ipynb b/Untitled.ipynb deleted file mode 100644 index 023ad11..0000000 --- a/Untitled.ipynb +++ /dev/null @@ -1,141 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "from support.utilities import *\n", - "from support.language_models import *\n", - "from support.norms import *\n", - "from cipher.keyword_cipher import *" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "def keyword_encipher_p(message, keyword, wrap_alphabet=KeywordWrapAlphabet.from_a):\n", - " cipher_alphabet = keyword_cipher_alphabet_of(keyword, wrap_alphabet)\n", - " cipher_translation = {p: c for p, c in zip(string.ascii_lowercase, cipher_alphabet)}\n", - " return cat(keyword_encipher_letter(letter, cipher_translation) for letter in message)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "def keyword_decipher_p(message, keyword, wrap_alphabet=KeywordWrapAlphabet.from_a):\n", - " cipher_alphabet = keyword_cipher_alphabet_of(keyword, wrap_alphabet)\n", - " plaintext_translation = {c: p for p, c in zip(string.ascii_lowercase, cipher_alphabet)}\n", - " return cat(keyword_encipher_letter(letter, plaintext_translation) for letter in message)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def keyword_encipher_letter(letter, cipher_translation):\n", - " if letter in cipher_translation:\n", - " return cipher_translation[letter]\n", - " else:\n", - " return letter" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'qopq hoppkdo'" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "keyword_encipher('test message', 'keyword')" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'qopq hoppkdo'" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "keyword_encipher_p('test message', 'keyword')" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'test message'" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "keyword_decipher_p('qopq hoppkdo', 'keyword')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}