{"id":1832,"date":"2024-03-11T16:27:57","date_gmt":"2024-03-11T15:27:57","guid":{"rendered":"https:\/\/blog.univ-angers.fr\/mathsinfo\/?p=1832"},"modified":"2024-03-11T16:28:21","modified_gmt":"2024-03-11T15:28:21","slug":"python-cryptographie-partie-5-autoclave","status":"publish","type":"post","link":"https:\/\/blog.univ-angers.fr\/mathsinfo\/2024\/03\/11\/python-cryptographie-partie-5-autoclave\/","title":{"rendered":"Python &amp; Cryptographie partie 5 : Autoclave"},"content":{"rendered":"\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Python &amp; Cryptographie partie 5 : Autoclave\" width=\"584\" height=\"329\" src=\"https:\/\/www.youtube.com\/embed\/l14drLQd6uc?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>def grille(a, b):\n    return chr(65 + (ord(a) + ord(b)) % 26)\n\ndef invGrille(a, b):\n    return chr(65 + (ord(a) - ord(b)) % 26)\n\ndef chiffreAutoclaveV1(phrase:str, cle:str):\n    phrase = phrase.upper()\n    chiffre = ''\n    for c in phrase:\n        cle = grille(c, cle)\n        chiffre += cle\n    return chiffre\n\ndef dechiffreAutoclaveV1(chiffre:str, cle:str):\n    clair = ''\n    for c in chiffre:\n        clair += invGrille(c, cle)\n        cle = c\n    return clair    \n  \nphrase = 'OPERATIONURGENTE'\ncle = 'K'\nchiffre = chiffreAutoclaveV1(phrase, cle)\nprint('Chiffr\u00e9e :', chiffre)\nprint('D\u00e9chiffr\u00e9e :', dechiffreAutoclaveV1(chiffre, cle))\n\n\ndef chiffreAutoclaveV2(phrase:str, mot:str):\n    phrase = phrase.upper()\n    cle = mot.upper() + phrase\n    chiffre = ''\n    for i, c in enumerate(phrase): chiffre += grille(c, cle&#091;i])\n    return chiffre\n\ndef dechiffreAutoclaveV2(chiffre:str, mot:str):\n    clair = ''\n    cle = mot\n    for i, c in enumerate(chiffre):\n        lettre = invGrille(c, cle&#091;i])\n        clair += lettre\n        cle += lettre\n    return clair\n\nphrase = 'MESSAGEIMPORTANTPOURNESTORLAGIRAFEAUNLONGCOU'\nmot = 'POIRIER'\nchiffre = chiffreAutoclaveV2(phrase, mot)\nprint('Chiffr\u00e9e :', chiffre)\nprint('D\u00e9chiffr\u00e9e :', dechiffreAutoclaveV2(chiffre, mot))\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":4913,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1832","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/users\/4913"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/comments?post=1832"}],"version-history":[{"count":2,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1832\/revisions"}],"predecessor-version":[{"id":1834,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1832\/revisions\/1834"}],"wp:attachment":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/media?parent=1832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/categories?post=1832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/tags?post=1832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}