<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.openssl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.openssl-get-cipher-methods.php',
    1 => 'openssl_get_cipher_methods',
    2 => 'Gets available cipher methods',
  ),
  'up' => 
  array (
    0 => 'ref.openssl.php',
    1 => 'OpenSSL Functions',
  ),
  'prev' => 
  array (
    0 => 'function.openssl-get-cert-locations.php',
    1 => 'openssl_get_cert_locations',
  ),
  'next' => 
  array (
    0 => 'function.openssl-get-curve-names.php',
    1 => 'openssl_get_curve_names',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/openssl/functions/openssl-get-cipher-methods.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.openssl-get-cipher-methods" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_get_cipher_methods</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">openssl_get_cipher_methods</span> &mdash; <span class="dc-title">Gets available cipher methods</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.openssl-get-cipher-methods-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_get_cipher_methods</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$aliases</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   Gets a list of available cipher methods.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-get-cipher-methods-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">aliases</code></dt>
     <dd>
      <p class="para">
       Set to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if cipher aliases should be included within the
       returned <span class="type"><a href="language.types.array.php" class="type array">array</a></span>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-get-cipher-methods-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   An <span class="type"><a href="language.types.array.php" class="type array">array</a></span> of available cipher methods.
   Note that prior to OpenSSL 1.1.1, the cipher methods have been returned in
   upper case and lower case spelling; as of OpenSSL 1.1.1 only the lower case
   variants are returned.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.openssl-get-cipher-methods-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>openssl_get_cipher_methods()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     Shows how the available ciphers might look, and also which aliases
     might be available.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$ciphers             </span><span style="color: #007700">= </span><span style="color: #0000BB">openssl_get_cipher_methods</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$ciphers_and_aliases </span><span style="color: #007700">= </span><span style="color: #0000BB">openssl_get_cipher_methods</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cipher_aliases      </span><span style="color: #007700">= </span><span style="color: #0000BB">array_diff</span><span style="color: #007700">(</span><span style="color: #0000BB">$ciphers_and_aliases</span><span style="color: #007700">, </span><span style="color: #0000BB">$ciphers</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//ECB mode should be avoided<br /></span><span style="color: #0000BB">$ciphers </span><span style="color: #007700">= </span><span style="color: #0000BB">array_filter</span><span style="color: #007700">( </span><span style="color: #0000BB">$ciphers</span><span style="color: #007700">, function(</span><span style="color: #0000BB">$n</span><span style="color: #007700">) { return </span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$n</span><span style="color: #007700">,</span><span style="color: #DD0000">"ecb"</span><span style="color: #007700">)===</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">; } );<br /><br /></span><span style="color: #FF8000">//At least as early as Aug 2016, Openssl declared the following weak: RC2, RC4, DES, 3DES, MD5 based<br /></span><span style="color: #0000BB">$ciphers </span><span style="color: #007700">= </span><span style="color: #0000BB">array_filter</span><span style="color: #007700">( </span><span style="color: #0000BB">$ciphers</span><span style="color: #007700">, function(</span><span style="color: #0000BB">$c</span><span style="color: #007700">) { return </span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,</span><span style="color: #DD0000">"des"</span><span style="color: #007700">)===</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">; } );<br /></span><span style="color: #0000BB">$ciphers </span><span style="color: #007700">= </span><span style="color: #0000BB">array_filter</span><span style="color: #007700">( </span><span style="color: #0000BB">$ciphers</span><span style="color: #007700">, function(</span><span style="color: #0000BB">$c</span><span style="color: #007700">) { return </span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,</span><span style="color: #DD0000">"rc2"</span><span style="color: #007700">)===</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">; } );<br /></span><span style="color: #0000BB">$ciphers </span><span style="color: #007700">= </span><span style="color: #0000BB">array_filter</span><span style="color: #007700">( </span><span style="color: #0000BB">$ciphers</span><span style="color: #007700">, function(</span><span style="color: #0000BB">$c</span><span style="color: #007700">) { return </span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,</span><span style="color: #DD0000">"rc4"</span><span style="color: #007700">)===</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">; } );<br /></span><span style="color: #0000BB">$ciphers </span><span style="color: #007700">= </span><span style="color: #0000BB">array_filter</span><span style="color: #007700">( </span><span style="color: #0000BB">$ciphers</span><span style="color: #007700">, function(</span><span style="color: #0000BB">$c</span><span style="color: #007700">) { return </span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,</span><span style="color: #DD0000">"md5"</span><span style="color: #007700">)===</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">; } );<br /></span><span style="color: #0000BB">$cipher_aliases </span><span style="color: #007700">= </span><span style="color: #0000BB">array_filter</span><span style="color: #007700">(</span><span style="color: #0000BB">$cipher_aliases</span><span style="color: #007700">,function(</span><span style="color: #0000BB">$c</span><span style="color: #007700">) { return </span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,</span><span style="color: #DD0000">"des"</span><span style="color: #007700">)===</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">; } );<br /></span><span style="color: #0000BB">$cipher_aliases </span><span style="color: #007700">= </span><span style="color: #0000BB">array_filter</span><span style="color: #007700">(</span><span style="color: #0000BB">$cipher_aliases</span><span style="color: #007700">,function(</span><span style="color: #0000BB">$c</span><span style="color: #007700">) { return </span><span style="color: #0000BB">stripos</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">,</span><span style="color: #DD0000">"rc2"</span><span style="color: #007700">)===</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">; } );<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$ciphers</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$cipher_aliases</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
    [0] =&gt; aes-128-cbc
    [1] =&gt; aes-128-cbc-hmac-sha1
    [2] =&gt; aes-128-cbc-hmac-sha256
    [3] =&gt; aes-128-ccm
    [4] =&gt; aes-128-cfb
    [5] =&gt; aes-128-cfb1
    [6] =&gt; aes-128-cfb8
    [7] =&gt; aes-128-ctr
    [9] =&gt; aes-128-gcm
    [10] =&gt; aes-128-ocb
    [11] =&gt; aes-128-ofb
    [12] =&gt; aes-128-xts
    [13] =&gt; aes-192-cbc
    [14] =&gt; aes-192-ccm
    [15] =&gt; aes-192-cfb
    [16] =&gt; aes-192-cfb1
    [17] =&gt; aes-192-cfb8
    [18] =&gt; aes-192-ctr
    [20] =&gt; aes-192-gcm
    [21] =&gt; aes-192-ocb
    [22] =&gt; aes-192-ofb
    [23] =&gt; aes-256-cbc
    [24] =&gt; aes-256-cbc-hmac-sha1
    [25] =&gt; aes-256-cbc-hmac-sha256
    [26] =&gt; aes-256-ccm
    [27] =&gt; aes-256-cfb
    [28] =&gt; aes-256-cfb1
    [29] =&gt; aes-256-cfb8
    [30] =&gt; aes-256-ctr
    [32] =&gt; aes-256-gcm
    [33] =&gt; aes-256-ocb
    [34] =&gt; aes-256-ofb
    [35] =&gt; aes-256-xts
    [36] =&gt; aria-128-cbc
    [37] =&gt; aria-128-ccm
    [38] =&gt; aria-128-cfb
    [39] =&gt; aria-128-cfb1
    [40] =&gt; aria-128-cfb8
    [41] =&gt; aria-128-ctr
    [43] =&gt; aria-128-gcm
    [44] =&gt; aria-128-ofb
    [45] =&gt; aria-192-cbc
    [46] =&gt; aria-192-ccm
    [47] =&gt; aria-192-cfb
    [48] =&gt; aria-192-cfb1
    [49] =&gt; aria-192-cfb8
    [50] =&gt; aria-192-ctr
    [52] =&gt; aria-192-gcm
    [53] =&gt; aria-192-ofb
    [54] =&gt; aria-256-cbc
    [55] =&gt; aria-256-ccm
    [56] =&gt; aria-256-cfb
    [57] =&gt; aria-256-cfb1
    [58] =&gt; aria-256-cfb8
    [59] =&gt; aria-256-ctr
    [61] =&gt; aria-256-gcm
    [62] =&gt; aria-256-ofb
    [63] =&gt; bf-cbc
    [64] =&gt; bf-cfb
    [66] =&gt; bf-ofb
    [67] =&gt; camellia-128-cbc
    [68] =&gt; camellia-128-cfb
    [69] =&gt; camellia-128-cfb1
    [70] =&gt; camellia-128-cfb8
    [71] =&gt; camellia-128-ctr
    [73] =&gt; camellia-128-ofb
    [74] =&gt; camellia-192-cbc
    [75] =&gt; camellia-192-cfb
    [76] =&gt; camellia-192-cfb1
    [77] =&gt; camellia-192-cfb8
    [78] =&gt; camellia-192-ctr
    [80] =&gt; camellia-192-ofb
    [81] =&gt; camellia-256-cbc
    [82] =&gt; camellia-256-cfb
    [83] =&gt; camellia-256-cfb1
    [84] =&gt; camellia-256-cfb8
    [85] =&gt; camellia-256-ctr
    [87] =&gt; camellia-256-ofb
    [88] =&gt; cast5-cbc
    [89] =&gt; cast5-cfb
    [91] =&gt; cast5-ofb
    [92] =&gt; chacha20
    [93] =&gt; chacha20-poly1305
    [111] =&gt; id-aes128-CCM
    [112] =&gt; id-aes128-GCM
    [113] =&gt; id-aes128-wrap
    [114] =&gt; id-aes128-wrap-pad
    [115] =&gt; id-aes192-CCM
    [116] =&gt; id-aes192-GCM
    [117] =&gt; id-aes192-wrap
    [118] =&gt; id-aes192-wrap-pad
    [119] =&gt; id-aes256-CCM
    [120] =&gt; id-aes256-GCM
    [121] =&gt; id-aes256-wrap
    [122] =&gt; id-aes256-wrap-pad
    [124] =&gt; idea-cbc
    [125] =&gt; idea-cfb
    [127] =&gt; idea-ofb
    [137] =&gt; seed-cbc
    [138] =&gt; seed-cfb
    [140] =&gt; seed-ofb
    [141] =&gt; sm4-cbc
    [142] =&gt; sm4-cfb
    [143] =&gt; sm4-ctr
    [145] =&gt; sm4-ofb
)
Array
(
    [36] =&gt; aes128
    [37] =&gt; aes128-wrap
    [38] =&gt; aes192
    [39] =&gt; aes192-wrap
    [40] =&gt; aes256
    [41] =&gt; aes256-wrap
    [69] =&gt; aria128
    [70] =&gt; aria192
    [71] =&gt; aria256
    [72] =&gt; bf
    [77] =&gt; blowfish
    [99] =&gt; camellia128
    [100] =&gt; camellia192
    [101] =&gt; camellia256
    [102] =&gt; cast
    [103] =&gt; cast-cbc
    [146] =&gt; idea
    [164] =&gt; seed
    [169] =&gt; sm4
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.openssl-get-cipher-methods-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.openssl-get-md-methods.php" class="function" rel="rdfs-seeAlso">openssl_get_md_methods()</a> - Gets available digest methods</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>