util_format.h 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. /* Copyright (c) 2001, Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2015, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef TOR_UTIL_FORMAT_H
  7. #define TOR_UTIL_FORMAT_H
  8. #include "testsupport.h"
  9. #include "torint.h"
  10. #define BASE64_ENCODE_MULTILINE 1
  11. size_t base64_encode_size(size_t srclen, int flags);
  12. int base64_encode(char *dest, size_t destlen, const char *src, size_t srclen,
  13. int flags);
  14. int base64_decode(char *dest, size_t destlen, const char *src, size_t srclen);
  15. int base64_encode_nopad(char *dest, size_t destlen,
  16. const uint8_t *src, size_t srclen);
  17. int base64_decode_nopad(uint8_t *dest, size_t destlen,
  18. const char *src, size_t srclen);
  19. /** Characters that can appear (case-insensitively) in a base32 encoding. */
  20. #define BASE32_CHARS "abcdefghijklmnopqrstuvwxyz234567"
  21. void base32_encode(char *dest, size_t destlen, const char *src, size_t srclen);
  22. int base32_decode(char *dest, size_t destlen, const char *src, size_t srclen);
  23. int hex_decode_digit(char c);
  24. void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen);
  25. int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen);
  26. #endif