3
/* Copyright 2009 10gen Inc.
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
24
typedef unsigned char md5digest[16];
26
inline void md5(const void *buf, int nbytes, md5digest digest) {
29
md5_append(&st, (const md5_byte_t *) buf, nbytes);
30
md5_finish(&st, digest);
33
inline void md5(const char *str, md5digest digest) {
34
md5(str, strlen(str), digest);
37
inline std::string digestToString( md5digest digest ){
38
static const char * letters = "0123456789abcdef";
40
for ( int i=0; i<16; i++){
41
unsigned char c = digest[i];
42
ss << letters[ ( c >> 4 ) & 0xf ] << letters[ c & 0xf ];
47
inline std::string md5simpledigest( string s ){
50
return digestToString( d );