| 1 | /* |
| 2 | * Copyright 2008-2018 Aerospike, Inc. |
| 3 | * |
| 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
| 5 | * license agreements. |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 8 | * use this file except in compliance with the License. You may obtain a copy of |
| 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | * License for the specific language governing permissions and limitations under |
| 15 | * the License. |
| 16 | */ |
| 17 | |
| 18 | /** |
| 19 | * A general purpose hashtable implementation |
| 20 | * Good at multithreading |
| 21 | * Just, hopefully, the last reasonable hash table you'll ever need |
| 22 | */ |
| 23 | #include <citrusleaf/cf_crypto.h> |
| 24 | #include <stdio.h> |
| 25 | |
| 26 | /****************************************************************************** |
| 27 | * FUNCTIONS |
| 28 | ******************************************************************************/ |
| 29 | /** |
| 30 | * cf_convert_sha1_to_hex |
| 31 | * Desc: Convert a sha1 returned hash to a hexadecimal string. |
| 32 | */ |
| 33 | bool |
| 34 | cf_convert_sha1_to_hex(unsigned char * hash, unsigned char * sha1_hex_buff) |
| 35 | { |
| 36 | if (!sha1_hex_buff || !hash) { |
| 37 | return false; |
| 38 | } |
| 39 | |
| 40 | for (unsigned int i = 0; i < SHA_DIGEST_LENGTH; i++) { |
| 41 | sprintf((char *)(sha1_hex_buff + (i * 2)), "%02x" , hash[i]); |
| 42 | } |
| 43 | return true; |
| 44 | } |
| 45 | |