source: roaraudio/libroar/hash.c @ 4450:9cf317562718

Last change on this file since 4450:9cf317562718 was 4450:9cf317562718, checked in by phi, 14 years ago

implemented some functions for hashing

File size: 3.7 KB
Line 
1//hash.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010
5 *
6 *  This file is part of libroar a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  libroar is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 *  NOTE for everyone want's to change something and send patches:
25 *  read README and HACKING! There a addition information on
26 *  the license of this document you need to read before you send
27 *  any patches.
28 *
29 *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
30 *  or libpulse*:
31 *  The libs libroaresd, libroararts and libroarpulse link this lib
32 *  and are therefore GPL. Because of this it may be illigal to use
33 *  them with any software that uses libesd, libartsc or libpulse*.
34 */
35
36#include "libroar.h"
37
38static const struct hashes {
39 const int    id;
40 const char * name;
41} _libroar_hashes[] = {
42/*
43grep '^  +HT_' doc/new-cmds | sed 's/ *#(.*)$//; s/^  +HT_//; s/ *=.*$//' | while read n; do printf " {ROAR_HT_%-12s \"%-12s},\n" $n, $n\"; done
44*/
45 {ROAR_HT_NONE,        "NONE"       },
46 {ROAR_HT_MD5,         "MD5"        },
47 {ROAR_HT_SHA1,        "SHA1"       },
48 {ROAR_HT_RIPEMD160,   "RIPEMD160"  },
49 {ROAR_HT_MD2,         "MD2"        },
50 {ROAR_HT_TIGER,       "TIGER"      },
51 {ROAR_HT_HAVAL,       "HAVAL"      },
52 {ROAR_HT_SHA256,      "SHA256"     },
53 {ROAR_HT_SHA384,      "SHA384"     },
54 {ROAR_HT_SHA512,      "SHA512"     },
55 {ROAR_HT_SHA224,      "SHA224"     },
56 {ROAR_HT_MD4,         "MD4"        },
57 {ROAR_HT_CRC32,       "CRC32"      },
58 {ROAR_HT_RFC1510,     "RFC1510"    },
59 {ROAR_HT_RFC2440,     "RFC2440"    },
60 {ROAR_HT_WHIRLPOOL,   "WHIRLPOOL"  },
61 {ROAR_HT_UUID,        "UUID"       },
62 {ROAR_HT_GTN8,        "GTN8"       },
63 {ROAR_HT_GTN16,       "GTN16"      },
64 {ROAR_HT_GTN32,       "GTN32"      },
65 {ROAR_HT_GTN64,       "GTN64"      },
66 {ROAR_HT_CLIENTID,    "CLIENTID"   },
67 {ROAR_HT_STREAMID,    "STREAMID"   },
68 {ROAR_HT_SOURCEID,    "SOURCEID"   },
69 {ROAR_HT_SAMPLEID,    "SAMPLEID"   },
70 {ROAR_HT_MIXERID,     "MIXERID"    },
71 {ROAR_HT_BRIDGEID,    "BRIDGEID"   },
72 {ROAR_HT_LISTENID,    "LISTENID"   },
73 {ROAR_HT_ACTIONID,    "ACTIONID"   },
74 {ROAR_HT_MSGQUEUEID,  "MSGQUEUEID" },
75 {ROAR_HT_MSGBUSID,    "MSGBUSID"   },
76 {ROAR_HT_GTIN8,       "GTIN8"      },
77 {ROAR_HT_GTIN13,      "GTIN13"     },
78 {ROAR_HT_ISBN10,      "ISBN10"     },
79 {ROAR_HT_ISBN13,      "ISBN13"     },
80 {-1, NULL}
81};
82
83const char * roar_ht2str (const int    ht) {
84 int i;
85
86 for (i = 0; _libroar_hashes[i].id != -1; i++)
87  if ( _libroar_hashes[i].id == ht )
88   return _libroar_hashes[i].name;
89
90 return NULL;
91}
92
93int          roar_str2ht (const char * ht) {
94 int i;
95
96 for (i = 0; _libroar_hashes[i].id != -1; i++)
97  if ( !strcasecmp(_libroar_hashes[i].name, ht) )
98   return _libroar_hashes[i].id;
99
100 return -1;
101}
102
103int roar_hash_buffer(void * digest, const void * data, size_t datalen, int algo) {
104 return roar_hash_salted_buffer(digest, data, datalen, algo, NULL, 0);
105}
106
107int roar_hash_salted_buffer(void * digest, const void * data, size_t datalen, int algo, const void * salt, size_t saltlen) {
108 return -1;
109}
110
111//ll
Note: See TracBrowser for help on using the repository browser.