hash.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <refentry id="refhash">
  2. <refmeta>
  3. <refentrytitle>ne_strhash</refentrytitle>
  4. <manvolnum>3</manvolnum>
  5. </refmeta>
  6. <refnamediv>
  7. <refname id="ne_strhash">ne_strhash</refname>
  8. <refname id="ne_vstrhash">ne_vstrhash</refname>
  9. <refpurpose>string hash interface</refpurpose>
  10. </refnamediv>
  11. <refsynopsisdiv>
  12. <funcsynopsis>
  13. <funcsynopsisinfo>#include &lt;ne_string.h&gt;</funcsynopsisinfo>
  14. <funcprototype>
  15. <funcdef>char *<function>ne_strhash</function></funcdef>
  16. <paramdef>unsigned int <parameter>flags</parameter></paramdef>
  17. <paramdef><parameter>...</parameter></paramdef>
  18. </funcprototype>
  19. <funcprototype>
  20. <funcdef>char *<function>ne_vstrhash</function></funcdef>
  21. <paramdef>unsigned int <parameter>flags</parameter></paramdef>
  22. <paramdef>va_list <parameter>ap</parameter></paramdef>
  23. </funcprototype>
  24. </funcsynopsis>
  25. </refsynopsisdiv>
  26. <refsect1>
  27. <title>Description</title>
  28. <para>The <function>ne_strhash</function> and
  29. <function>ne_vstrhash</function> functions can be used to
  30. create hashes. The varargs argument list must be <type>const
  31. char *</type> strings followed by a &null; terminator. The
  32. <parameter>flags</parameter> argument must select exactly one
  33. hash algorithm from the list below, which can be optionally
  34. bitwise-ORed with one of the formatting option. The hash is
  35. calculated for the concatenation of the argument list, without
  36. separators.</para>
  37. <refsect2>
  38. <title>Hash algorithms</title>
  39. <para>The following hash algorithms are available:
  40. <variablelist>
  41. <varlistentry>
  42. <term><constant>NE_HASH_MD5</constant></term>
  43. <listitem><simpara>MD5</simpara></listitem>
  44. </varlistentry>
  45. <varlistentry>
  46. <term><constant>NE_HASH_SHA256</constant></term>
  47. <listitem><simpara>SHA-256 (SHA-2)</simpara></listitem>
  48. </varlistentry>
  49. <varlistentry>
  50. <term><constant>NE_HASH_SHA512</constant></term>
  51. <listitem><simpara>SHA-512 (SHA-2)</simpara></listitem>
  52. </varlistentry>
  53. <varlistentry>
  54. <term><constant>NE_HASH_SHA256_256</constant></term>
  55. <listitem><simpara>SHA-512/256 (SHA-2)</simpara></listitem>
  56. </varlistentry>
  57. </variablelist>
  58. </para></refsect2>
  59. <refsect2>
  60. <title>Formatting options</title>
  61. <para>By default, the hash is returned as a hexadecimal
  62. lower-case character string. The following formatting
  63. options are available:
  64. <variablelist>
  65. <varlistentry>
  66. <term><constant>NE_HASH_COLON</constant></term>
  67. <listitem><simpara>colon-separated hex pairs, e.g. <literal>"aa:11:22..."</literal> </simpara></listitem>
  68. </varlistentry>
  69. <varlistentry>
  70. <term><constant>NE_HASH_SPACE</constant></term>
  71. <listitem><simpara>space-separated hex pairs, e.g. <literal>"aa 11 22..."</literal></simpara></listitem>
  72. </varlistentry>
  73. </variablelist></para>
  74. </refsect2>
  75. </refsect1>
  76. <refsect1>
  77. <title>Return value</title>
  78. <para>The return value is the ASCII hexadecimal representation
  79. of the hash as a malloc-allocated, NUL-terminated string, or
  80. &null; if the hash cannot be created. The string length is
  81. determined by the hash algorithm (and formatting options
  82. used). Support for hash algorithms is specific to the SSL
  83. toolkit with which &neon; is compiled. Some systems will
  84. further restrict hash availability at runtime, e.g. due to
  85. FIPS mode.</para>
  86. </refsect1>
  87. <refsect1>
  88. <title>History</title>
  89. <para><function>ne_strhash</function> and <function>ne_vstrhash</function> is
  90. available in &neon; 0.32.0 and later.</para>
  91. </refsect1>
  92. </refentry>