1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
8 * \brief Implements SHA1 creation over WRBUF
19 #include <yaz/wrbuf.h>
24 int wrbuf_sha1_write(WRBUF b, const char *cp, size_t sz, int hexit)
29 const unsigned char *digest_buf;
30 int digest_len = gcry_md_get_algo_dlen(GCRY_MD_SHA1);
32 e = gcry_md_open(&hd, GCRY_MD_SHA1, 0);
35 gcry_md_write(hd, cp, sz);
37 digest_buf = gcry_md_read(hd, GCRY_MD_SHA1);
41 for (i = 0; i < digest_len; i++)
42 wrbuf_printf(b, "%02x", digest_buf[i]);
45 wrbuf_write(b, (const char *) digest_buf, digest_len);
53 int wrbuf_sha1_puts(WRBUF b, const char *cp, int hexit)
55 return wrbuf_sha1_write(b, cp, strlen(cp), hexit);
61 * c-file-style: "Stroustrup"
62 * indent-tabs-mode: nil
64 * vim: shiftwidth=4 tabstop=8 expandtab