4958c113ba3b025e1d83daad66c83df7ccd5f877
[scilab.git] / scilab / modules / fileio / help / en_US / hash.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) 2020 - St├ęphane MOTTELET
5  *
6  * This file is hereby licensed under the terms of the GNU GPL v2.0,
7  * For more information, see the COPYING file which you should have received
8  * along with this program.
9  *
10  -->
11 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="hash">
12     <refnamediv>
13         <refname>hash</refname>
14         <refpurpose>get checksum of file or string using various digest algorithms</refpurpose>
15     </refnamediv>
16     <refsynopsisdiv>
17         <title>Syntax</title>
18         <synopsis>res = hash(fd, algorithm)
19             res = hash(string, algorithm)
20         </synopsis>
21     </refsynopsisdiv>
22     <refsection>
23         <title>Arguments</title>
24         <variablelist>
25             <varlistentry>
26                 <term>res</term>
27                 <listitem>
28                     <para>hash result (a string)</para>
29                 </listitem>
30             </varlistentry>
31             <varlistentry>
32                 <term>fd</term>
33                 <listitem>
34                     <para>a matrix of file descriptors returned by the function mopen.</para>
35                 </listitem>
36             </varlistentry>
37             <varlistentry>
38                 <term>string</term>
39                 <listitem>
40                     <para>a string or a matrix of strings</para>
41                 </listitem>
42             </varlistentry>
43             <varlistentry>
44                 <term>algorithm</term>
45                 <listitem>
46                     <para>a string (the hashing algorithm)</para>
47                 </listitem>
48             </varlistentry>
49         </variablelist>
50     </refsection>
51     <refsection>
52         <title>Description</title>
53         <para>
54             <function>hash</function> get the checksum of a file or a string using the hashing function <term>algorithm</term>. The available functions are:
55         </para>
56         <para>
57         <informaltable border="1">
58                <tbody>
59                  <tr>
60                      <td>'crc32'</td><td>crc32 chechsum</td>
61                  </tr>
62                  <tr>
63                      <td>'md5'</td><td>Message-Digest Algorithm 5</td>
64                  </tr>
65                 <tr>
66                     <td>'sha1'</td><td>Secure Hash Algorithm 1 (160 bits)</td>
67                 </tr>
68                 <tr>
69                     <td>'sha2', 'sha256'</td><td>Secure Hash Algorithm 2 (256 bits)</td>
70                 </tr>
71                 <tr>
72                     <td>'sha3-224'</td><td>Secure Hash Algorithm 3 (224 bits)</td>
73                 </tr>
74                 <tr>
75                     <td>'sha3-256'</td><td>Secure Hash Algorithm 3 (256 bits)</td>
76                 </tr>
77                 <tr>
78                     <td>'sha3-384'</td><td>Secure Hash Algorithm 3 (384 bits)</td>
79                 </tr>
80                 <tr>
81                     <td>'sha3-512'</td><td>Secure Hash Algorithm 3 (512 bits)</td>
82                 </tr>
83             </tbody>
84         </informaltable>
85     </para>
86     </refsection>
87     <refsection>
88         <title>Examples</title>
89         <programlisting role="example"><![CDATA[
90 hash('hello world', 'md5')
91 hash('hello world', 'sha256')
92 hash(['hello';'world'], 'sha3-256')
93
94 hash( mopen(SCI+'/modules/core/etc/core.start') ,'sha256')
95  ]]></programlisting>
96     </refsection>
97       <refsection>
98         <title>History</title>
99         <revhistory>
100             <revision>
101                 <revnumber>6.1.1</revnumber>
102                 <revremark>hash() introduced.</revremark>
103             </revision>
104         </revhistory>
105     </refsection>
106 </refentry>