{"id":5798,"date":"2025-12-13T17:52:15","date_gmt":"2025-12-13T16:52:15","guid":{"rendered":"https:\/\/workboot.fr\/ciela\/?page_id=5798"},"modified":"2025-12-13T18:28:06","modified_gmt":"2025-12-13T17:28:06","slug":"hachage-hash","status":"publish","type":"page","link":"https:\/\/workboot.fr\/ciela\/hachage-hash\/","title":{"rendered":"Hash"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">D\u00e9finition :<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Un hash, c&rsquo;est une empreinte digitale num\u00e9rique unique et de taille fixe cr\u00e9\u00e9e \u00e0 partir de n&rsquo;importe quelle donn\u00e9e, qui permet de l&rsquo;identifier et de v\u00e9rifier qu&rsquo;elle n&rsquo;a pas \u00e9t\u00e9 modifi\u00e9e.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Un exemple de code pour comprendre la  notion de hash !<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">hash_simple.c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;stdio.h>\n\n\/* Fonction hash tr\u00e8s simple *\/\nint hash_simple(char *mot) \n{\n    int code = 0;    \n    while (*mot != '\\0') {\n        code = code + *mot;  \/* Additionne les codes des lettres *\/\n        mot++;\n    }    \n    return code % 100;  \/* Garde juste 2 chiffres *\/\n}\n\nint main() \n{\n    printf(\"Hash de 'chat' : %d\\n\", hash_simple(\"chat\"));\n    printf(\"Hash de 'chien' : %d\\n\", hash_simple(\"chien\"));\n    printf(\"Hash de 'chat' \u00e0 nouveau : %d\\n\", hash_simple(\"chat\"));   \n    return EXIT_SUCCESS;\n}<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Hash de 'chat' : 42\nHash de 'chien' : 57  \nHash de 'chat' \u00e0 nouveau : 42  \u2190 Toujours pareil!<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Sous Linux il existe des outils de Hash puissant :<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. Cr\u00e9e un fichier\necho \"Mon premier hash\" &gt; test.txt\n\n# 2. Vois son empreinte\nmd5sum test.txt\n\n# 3. Modifie-le un tout petit peu\necho \"Mon premier hash!\" &gt; test.txt  # Ajout d'un '!'\n\n# 4. Vois comme l'empreinte change compl\u00e8tement!\nmd5sum test.txt<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Sous linux le fichier shadow  utilise le hash<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>etudiant:$y$j9T$PyMT0isnkPIZyB6gthk9r0$cGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5:<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">20280:<\/mark>0:99999:7:::<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">pour information le mot de passe ici est \u00ab\u00a0etudiant\u00a0\u00bb<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Champ par champ :<\/strong><\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong><code>etudiant:<\/code><\/strong>&nbsp;\u2192 Nom d&rsquo;utilisateur<\/li>\n\n\n\n<li><strong><code>$y$j9T$PyMT0isnkPIZyB6gthk9r0$cGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5<\/code><\/strong>&nbsp;\u2192 Hash du mot de passe (d\u00e9taill\u00e9 ci-dessous)<\/li>\n\n\n\n<li><strong><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">20280<\/mark><\/code><\/strong>&nbsp;\u2192 Date du dernier changement (en jours depuis le 1er janvier 1970)<\/li>\n\n\n\n<li><strong><code>0<\/code><\/strong>&nbsp;\u2192 \u00c2ge minimum avant changement (0 = peut changer imm\u00e9diatement)<\/li>\n\n\n\n<li><strong><code>99999<\/code><\/strong>&nbsp;\u2192 \u00c2ge maximum avant expiration (99999 = jamais)<\/li>\n\n\n\n<li><strong><code>7<\/code><\/strong>&nbsp;\u2192 P\u00e9riode d&rsquo;avertissement avant expiration (7 jours)<\/li>\n\n\n\n<li><strong><code>:<\/code><\/strong>&nbsp;\u2192 P\u00e9riode de gr\u00e2ce apr\u00e8s expiration (vide = aucune)<\/li>\n\n\n\n<li><strong><code>:<\/code><\/strong>&nbsp;\u2192 Date d&rsquo;expiration absolue (vide = jamais)<\/li>\n\n\n\n<li><strong><code>:<\/code><\/strong>&nbsp;\u2192 R\u00e9serv\u00e9 pour usage futur<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Analyse du Hash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$y$j9T$PyMT0isnkPIZyB6gthk9r0$cGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$y$ : est l\u2019algorithme utilis\u00e9. Algorithme yescrypt (moderne, s\u00e9curis\u00e9)\nj9T : Sel (salt). Salt (3 caract\u00e8res - la partie \"publique\" pour rendre le hash unique)\n$   : s\u00e9parateur\n\nPyMT0isnkPIZyB6gthk9r0 : Sel compl\u00e9t\u00e9 (22 caract\u00e8res en base64)\nGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5 : Hash r\u00e9el (43 caract\u00e8res)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Tester un mot de passe avec ce hash<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install whois<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>echo -n \"etudiant\" | mkpasswd --method=yescrypt --salt='$y$j9T$PyMT0isnkPIZyB6gthk9r0' --stdin | grep -q '\\$y\\$j9T\\$PyMT0isnkPIZyB6gthk9r0\\$cGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5' &amp;&amp; echo \"OK\" || echo \"KO\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">on test  le hash en une ligne .<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>etudiant@ordi:~\/Works\/hash_salt\/bash$ echo -n \"<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">etudiant<\/mark>\" | mkpasswd --method=yescrypt --salt='$y$j9T$PyMT0isnkPIZyB6gthk9r0' --stdin | grep -q '\\$y\\$j9T\\$PyMT0isnkPIZyB6gthk9r0\\$cGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5' &amp;&amp; echo \"OK\" || echo \"KO\"\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">OK<\/mark>\netudiant@ordi:~\/Works\/hash_salt\/bash$ echo -n \"<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">etodiant<\/mark>\" | mkpasswd --method=yescrypt --salt='$y$j9T$PyMT0isnkPIZyB6gthk9r0' --stdin | grep -q '\\$y\\$j9T\\$PyMT0isnkPIZyB6gthk9r0\\$cGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5' &amp;&amp; echo \"OK\" || echo \"KO\"\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">KO<\/mark>\netudiant@ordi:~\/Works\/hash_salt\/bash$ \n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">un petit script shell:<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\necho \"=== V\u00e9rificateur de Hash Yescrypt ===\"\necho\n\n# Demander le mot de passe (ne s'affiche pas \u00e0 l'\u00e9cran)\nread -sp \"Entrez le mot de passe: \" password\necho\n\n# Hash connu de \/etc\/shadow\nknown_hash=\"\\$y\\$j9T\\$PyMT0isnkPIZyB6gthk9r0\\$cGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5\"\n\n# Extraire le sel du hash connu\nsalt=$(echo \"$known_hash\" | cut -d'$' -f1-4)\n\necho \"Sel extrait: $salt\"\necho\n\n# G\u00e9n\u00e9rer le hash avec le m\u00eame sel\nif command -v mkpasswd >\/dev\/null 2>&amp;1; then\n    generated_hash=$(echo -n \"$password\" | mkpasswd --method=yescrypt --salt=\"$salt\" --stdin)\nelif command -v python3 >\/dev\/null 2>&amp;1; then\n    generated_hash=$(python3 -c \"import crypt; print(crypt.crypt('$password', '$salt'))\")\nelse\n    echo \"Erreur: ni mkpasswd ni python3 n'est install\u00e9\"\n    exit 1\nfi\n\necho \"Hash g\u00e9n\u00e9r\u00e9: $generated_hash\"\necho \"Hash connu:   $known_hash\"\necho\n\n# Comparaison\nif [ \"$generated_hash\" = \"$known_hash\" ]; then\n    echo \"\u2705 SUCC\u00c8S : Les hashs correspondent !\"\nelse\n    echo \"\u274c \u00c9CHEC : Les hashs sont diff\u00e9rents\"\n    echo \"Soit le mot de passe est incorrect, soit il y a un probl\u00e8me de sel\"\nfi\n<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>etudiant@ordi:~\/Works\/hash_salt\/bash$ .\/test_hash.sh \n=== V\u00e9rificateur de Hash Yescrypt ===\n\nEntrez le mot de passe: \nSel extrait: $y$j9T$PyMT0isnkPIZyB6gthk9r0\n\nHash g\u00e9n\u00e9r\u00e9: $y$j9T$PyMT0isnkPIZyB6gthk9r0$cGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5\nHash connu:   $y$j9T$PyMT0isnkPIZyB6gthk9r0$cGTbYOHh61zf3sRMnese.IZC0c7v5CCZCPMj8fO4MB5\n\n\u2705 SUCC\u00c8S : Les hashs correspondent !\netudiant@ordi:~\/Works\/hash_salt\/bash$ \n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>D\u00e9finition : Un hash, c&rsquo;est une empreinte digitale num\u00e9rique unique et de taille fixe cr\u00e9\u00e9e \u00e0 partir de n&rsquo;importe quelle donn\u00e9e, qui permet de l&rsquo;identifier et de v\u00e9rifier qu&rsquo;elle n&rsquo;a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-5798","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Hash - workboot<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/workboot.fr\/ciela\/hachage-hash\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hash - workboot\" \/>\n<meta property=\"og:description\" content=\"D\u00e9finition : Un hash, c&rsquo;est une empreinte digitale num\u00e9rique unique et de taille fixe cr\u00e9\u00e9e \u00e0 partir de n&rsquo;importe quelle donn\u00e9e, qui permet de l&rsquo;identifier et de v\u00e9rifier qu&rsquo;elle n&rsquo;a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/workboot.fr\/ciela\/hachage-hash\/\" \/>\n<meta property=\"og:site_name\" content=\"workboot\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-13T17:28:06+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/hachage-hash\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/hachage-hash\\\/\",\"name\":\"Hash - workboot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\"},\"datePublished\":\"2025-12-13T16:52:15+00:00\",\"dateModified\":\"2025-12-13T17:28:06+00:00\",\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/workboot.fr\\\/ciela\\\/hachage-hash\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"name\":\"workboot\",\"description\":\"Open Source, Open Minds \",\"publisher\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\",\"name\":\"workboot\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"contentUrl\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"width\":1024,\"height\":950,\"caption\":\"workboot\"},\"image\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hash - workboot","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/workboot.fr\/ciela\/hachage-hash\/","og_locale":"fr_FR","og_type":"article","og_title":"Hash - workboot","og_description":"D\u00e9finition : Un hash, c&rsquo;est une empreinte digitale num\u00e9rique unique et de taille fixe cr\u00e9\u00e9e \u00e0 partir de n&rsquo;importe quelle donn\u00e9e, qui permet de l&rsquo;identifier et de v\u00e9rifier qu&rsquo;elle n&rsquo;a [&hellip;]","og_url":"https:\/\/workboot.fr\/ciela\/hachage-hash\/","og_site_name":"workboot","article_modified_time":"2025-12-13T17:28:06+00:00","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/workboot.fr\/ciela\/hachage-hash\/","url":"https:\/\/workboot.fr\/ciela\/hachage-hash\/","name":"Hash - workboot","isPartOf":{"@id":"https:\/\/workboot.fr\/ciela\/#website"},"datePublished":"2025-12-13T16:52:15+00:00","dateModified":"2025-12-13T17:28:06+00:00","inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/workboot.fr\/ciela\/hachage-hash\/"]}]},{"@type":"WebSite","@id":"https:\/\/workboot.fr\/ciela\/#website","url":"https:\/\/workboot.fr\/ciela\/","name":"workboot","description":"Open Source, Open Minds ","publisher":{"@id":"https:\/\/workboot.fr\/ciela\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/workboot.fr\/ciela\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/workboot.fr\/ciela\/#organization","name":"workboot","url":"https:\/\/workboot.fr\/ciela\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/","url":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","contentUrl":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","width":1024,"height":950,"caption":"workboot"},"image":{"@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/"}}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/workboot.fr\/ciela\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"D\u00e9finition : Un hash, c&rsquo;est une empreinte digitale num\u00e9rique unique et de taille fixe cr\u00e9\u00e9e \u00e0 partir de n&rsquo;importe quelle donn\u00e9e, qui permet de l&rsquo;identifier et de v\u00e9rifier qu&rsquo;elle n&rsquo;a [&hellip;]","_links":{"self":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/5798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/comments?post=5798"}],"version-history":[{"count":12,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/5798\/revisions"}],"predecessor-version":[{"id":5820,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/5798\/revisions\/5820"}],"wp:attachment":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/media?parent=5798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}