hex.h 947 B

1234567891011121314151617181920212223242526
  1. /* hex.h - conversion for hexadecimal and base32 strings. */
  2. #ifndef HEX_H
  3. #define HEX_H
  4. #include "ustd.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. void rhash_byte_to_hex(char* dest, const unsigned char* src, size_t length, int upper_case);
  9. void rhash_byte_to_base32(char* dest, const unsigned char* src, size_t length, int upper_case);
  10. void rhash_byte_to_base64(char* dest, const unsigned char* src, size_t length);
  11. char* rhash_print_hex_byte(char* dest, const unsigned char byte, int upper_case);
  12. size_t rhash_urlencode(char* dst, const char* str, size_t size, int upper_case);
  13. size_t rhash_base64_url_encoded_helper(char* dst, const unsigned char* src, size_t length, int url_encode, int upper_case);
  14. int rhash_sprintI64(char* dst, uint64_t number);
  15. #define BASE32_LENGTH(bytes) (((bytes) * 8 + 4) / 5)
  16. #define BASE64_LENGTH(bytes) ((((bytes) + 2) / 3) * 4)
  17. #ifdef __cplusplus
  18. } /* extern "C" */
  19. #endif /* __cplusplus */
  20. #endif /* HEX_H */