]>
git.proxmox.com Git - libgit2.git/blob - src/hash.c
2 * Copyright (C) 2009-2011 the libgit2 contributors
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
12 # include "ppc/sha1.h"
21 git_hash_ctx
*git_hash_new_ctx(void)
23 git_hash_ctx
*ctx
= git__malloc(sizeof(*ctx
));
33 void git_hash_free_ctx(git_hash_ctx
*ctx
)
38 void git_hash_init(git_hash_ctx
*ctx
)
44 void git_hash_update(git_hash_ctx
*ctx
, const void *data
, size_t len
)
47 SHA1_Update(&ctx
->c
, data
, len
);
50 void git_hash_final(git_oid
*out
, git_hash_ctx
*ctx
)
53 SHA1_Final(out
->id
, &ctx
->c
);
56 void git_hash_buf(git_oid
*out
, const void *data
, size_t len
)
61 SHA1_Update(&c
, data
, len
);
62 SHA1_Final(out
->id
, &c
);
65 void git_hash_vec(git_oid
*out
, git_buf_vec
*vec
, size_t n
)
71 for (i
= 0; i
< n
; i
++)
72 SHA1_Update(&c
, vec
[i
].data
, vec
[i
].len
);
73 SHA1_Final(out
->id
, &c
);