<jupyter_start><jupyter_text>RSA in ECB modeSuppose that the RSA public key $(n, e) = (2491, 1595)$has been used to encrypt each individual character in a message $m$ (using their ASCII codes),giving the following ciphertext:$$c = (111, 2474, 1302, 1302, 1587, 395, 224, 313, 1587, 1047, 1302, 1341, 980).$$Determine the original message $m$ without factoring $n$.<jupyter_code>n = 2491
e = 1595
c = [111, 2474, 1302, 1302, 1587, 395, 224, 313, 1587, 1047, 1302, 1341, 980]<jupyter_output><empty_output><jupyter_text>Since there are only 128 ASCII characters, we can build a dictionary mapping encryptions to the corresponding codes.<jupyter_code>d = {pow(x, e, n): x for x in range(128)}
d<jupyter_output><empty_output><jupyter_text>We can now use the dictionary to decrypt each character.<jupyter_code>''.join(chr(d[y]) for y in c)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12166859791425261, 'fraction_numerical': 0.13441483198146004, 'mean_word_length': 6.322033898305085, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '65588', 'license': 'MIT', 'n_tokens_mistral': 408, 'n_tokens_neox': 304, 'n_words': 107, 'path': 'notebooks/RSA-ECB.ipynb', 'repo_name': 'tp4348/kirv', 'size': '863'}