|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- EN-Revision: 29cecd7f180bfdae00ebd6128b6dd4255eb30365 Maintainer: lacatoire Status: ready --> |
| 3 | +<!-- Reviewed: no --> |
| 4 | +<refentry xml:id="function.openssl-password-hash" xmlns="http://docbook.org/ns/docbook"> |
| 5 | + <refnamediv> |
| 6 | + <refname>openssl_password_hash</refname> |
| 7 | + <refpurpose>Crée un hachage de mot de passe en utilisant l'implémentation Argon2 d'OpenSSL</refpurpose> |
| 8 | + </refnamediv> |
| 9 | + |
| 10 | + <refsect1 role="description"> |
| 11 | + &reftitle.description; |
| 12 | + <methodsynopsis> |
| 13 | + <type>string</type><methodname>openssl_password_hash</methodname> |
| 14 | + <methodparam><type>string</type><parameter>algo</parameter></methodparam> |
| 15 | + <methodparam><type>string</type><parameter>password</parameter></methodparam> |
| 16 | + <methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam> |
| 17 | + </methodsynopsis> |
| 18 | + <para> |
| 19 | + Crée un hachage de mot de passe en utilisant l'implémentation Argon2 |
| 20 | + d'OpenSSL. Il s'agit d'une alternative à <function>password_hash</function> |
| 21 | + qui utilise OpenSSL comme moteur, ce qui peut offrir une accélération |
| 22 | + matérielle sur certaines plateformes. |
| 23 | + </para> |
| 24 | + <para> |
| 25 | + Cette fonction n'est disponible que lorsque PHP est compilé avec le |
| 26 | + support OpenSSL incluant Argon2 (<literal>HAVE_OPENSSL_ARGON2</literal>). |
| 27 | + </para> |
| 28 | + </refsect1> |
| 29 | + |
| 30 | + <refsect1 role="parameters"> |
| 31 | + &reftitle.parameters; |
| 32 | + <para> |
| 33 | + <variablelist> |
| 34 | + <varlistentry> |
| 35 | + <term><parameter>algo</parameter></term> |
| 36 | + <listitem> |
| 37 | + <para> |
| 38 | + L'algorithme de hachage du mot de passe. Valeurs supportées : |
| 39 | + <literal>"argon2id"</literal> et <literal>"argon2i"</literal>. |
| 40 | + </para> |
| 41 | + </listitem> |
| 42 | + </varlistentry> |
| 43 | + <varlistentry> |
| 44 | + <term><parameter>password</parameter></term> |
| 45 | + <listitem> |
| 46 | + <para> |
| 47 | + Le mot de passe de l'utilisateur. |
| 48 | + </para> |
| 49 | + </listitem> |
| 50 | + </varlistentry> |
| 51 | + <varlistentry> |
| 52 | + <term><parameter>options</parameter></term> |
| 53 | + <listitem> |
| 54 | + <para> |
| 55 | + Un &array; associatif d'options. Clés supportées : |
| 56 | + <simplelist> |
| 57 | + <member> |
| 58 | + <literal>memory_cost</literal> : mémoire maximale (en Kio) pouvant |
| 59 | + être utilisée pour calculer le hachage |
| 60 | + </member> |
| 61 | + <member> |
| 62 | + <literal>time_cost</literal> : temps maximal pouvant être pris pour |
| 63 | + calculer le hachage |
| 64 | + </member> |
| 65 | + <member> |
| 66 | + <literal>threads</literal> : nombre de threads à utiliser pour |
| 67 | + calculer le hachage |
| 68 | + </member> |
| 69 | + </simplelist> |
| 70 | + </para> |
| 71 | + </listitem> |
| 72 | + </varlistentry> |
| 73 | + </variablelist> |
| 74 | + </para> |
| 75 | + </refsect1> |
| 76 | + |
| 77 | + <refsect1 role="returnvalues"> |
| 78 | + &reftitle.returnvalues; |
| 79 | + <para> |
| 80 | + Retourne le hachage du mot de passe sous forme de &string;. |
| 81 | + </para> |
| 82 | + </refsect1> |
| 83 | + |
| 84 | + <refsect1 role="errors"> |
| 85 | + &reftitle.errors; |
| 86 | + <para> |
| 87 | + Lance une <classname>ValueError</classname> si <parameter>algo</parameter> |
| 88 | + n'est pas l'une des valeurs supportées |
| 89 | + (<literal>"argon2i"</literal> ou <literal>"argon2id"</literal>). |
| 90 | + </para> |
| 91 | + <para> |
| 92 | + Lance une <classname>Error</classname> si l'opération de hachage échoue |
| 93 | + pour une raison inconnue. |
| 94 | + </para> |
| 95 | + </refsect1> |
| 96 | + |
| 97 | + <refsect1 role="changelog"> |
| 98 | + &reftitle.changelog; |
| 99 | + <informaltable> |
| 100 | + <tgroup cols="2"> |
| 101 | + <thead> |
| 102 | + <row> |
| 103 | + <entry>&Version;</entry> |
| 104 | + <entry>&Description;</entry> |
| 105 | + </row> |
| 106 | + </thead> |
| 107 | + <tbody> |
| 108 | + <row> |
| 109 | + <entry>8.4.0</entry> |
| 110 | + <entry> |
| 111 | + Ajout de la fonction. |
| 112 | + </entry> |
| 113 | + </row> |
| 114 | + </tbody> |
| 115 | + </tgroup> |
| 116 | + </informaltable> |
| 117 | + </refsect1> |
| 118 | + |
| 119 | + <refsect1 role="examples"> |
| 120 | + &reftitle.examples; |
| 121 | + <example> |
| 122 | + <title>Exemple avec <function>openssl_password_hash</function></title> |
| 123 | + <programlisting role="php"> |
| 124 | +<![CDATA[ |
| 125 | +<?php |
| 126 | +$hash = openssl_password_hash('argon2id', 'mon-mot-de-passe-secret'); |
| 127 | +echo $hash; |
| 128 | +?> |
| 129 | +]]> |
| 130 | + </programlisting> |
| 131 | + &example.outputs.similar; |
| 132 | + <screen> |
| 133 | +<![CDATA[ |
| 134 | +$argon2id$v=19$m=65536,t=4,p=1$c29tZXNhbHR2YWx1ZQ$hashvalue... |
| 135 | +]]> |
| 136 | + </screen> |
| 137 | + </example> |
| 138 | + <example> |
| 139 | + <title><function>openssl_password_hash</function> avec des options personnalisées</title> |
| 140 | + <programlisting role="php"> |
| 141 | +<![CDATA[ |
| 142 | +<?php |
| 143 | +$hash = openssl_password_hash('argon2id', 'mon-mot-de-passe-secret', [ |
| 144 | + 'memory_cost' => 65536, |
| 145 | + 'time_cost' => 4, |
| 146 | + 'threads' => 1, |
| 147 | +]); |
| 148 | +?> |
| 149 | +]]> |
| 150 | + </programlisting> |
| 151 | + </example> |
| 152 | + </refsect1> |
| 153 | + |
| 154 | + <refsect1 role="seealso"> |
| 155 | + &reftitle.seealso; |
| 156 | + <para> |
| 157 | + <simplelist> |
| 158 | + <member><function>openssl_password_verify</function></member> |
| 159 | + <member><function>password_hash</function></member> |
| 160 | + </simplelist> |
| 161 | + </para> |
| 162 | + </refsect1> |
| 163 | + |
| 164 | +</refentry> |
| 165 | +<!-- Keep this comment at the end of the file |
| 166 | +Local variables: |
| 167 | +mode: sgml |
| 168 | +sgml-omittag:t |
| 169 | +sgml-shorttag:t |
| 170 | +sgml-minimize-attributes:nil |
| 171 | +sgml-always-quote-attributes:t |
| 172 | +sgml-indent-step:1 |
| 173 | +sgml-indent-data:t |
| 174 | +indent-tabs-mode:nil |
| 175 | +sgml-parent-document:nil |
| 176 | +sgml-default-dtd-file:"~/.phpdoc/manual.ced" |
| 177 | +sgml-exposed-tags:nil |
| 178 | +sgml-local-catalogs:nil |
| 179 | +sgml-local-ecat-files:nil |
| 180 | +End: |
| 181 | +vim600: syn=xml fen fdm=syntax fdl=2 si |
| 182 | +vim: et tw=78 syn=sgml |
| 183 | +vi: ts=1 sw=1 |
| 184 | +--> |
0 commit comments