{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "4f8f476d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(10, -1, 1)" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from rabin import encrypt, decrypt, encode, decode" ] }, { "cell_type": "code", "execution_count": 17, "id": "402fb09a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "81" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Verschlüsseln des Buchstaben \"j\" mit (p,q) = (11,19)\n", "p, q = 11, 19\n", "clear_text = \"j\"\n", "\n", "clear = encode(clear_text)\n", "cipher = encrypt(clear, p, q)\n", "\n", "cipher" ] }, { "cell_type": "code", "execution_count": 18, "id": "8264c687", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('j', 'ĩ', 'Ü', '·')" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Entschlüsseln unter Kenntnis des Schlüssels (p, q)\n", "possible_solutions = decrypt(cipher, p, q)\n", "\n", "tuple(map(decode, possible_solutions))" ] } ], "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.13.2" } }, "nbformat": 4, "nbformat_minor": 5 }