gBase64.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2013 Adam Rudd.
  3. * See LICENSE for more information
  4. */
  5. #ifndef _BASE64_H
  6. #define _BASE64_H
  7. /* b64_alphabet:
  8. * Description: Base64 alphabet table, a mapping between integers
  9. * and base64 digits
  10. * Notes: This is an extern here but is defined in Base64.c
  11. */
  12. extern const char b64_alphabet[];
  13. /* base64_encode:
  14. * Description:
  15. * Encode a string of characters as base64
  16. * Parameters:
  17. * output: the output buffer for the encoding, stores the encoded string
  18. * input: the input buffer for the encoding, stores the binary to be encoded
  19. * inputLen: the length of the input buffer, in bytes
  20. * Return value:
  21. * Returns the length of the encoded string
  22. * Requirements:
  23. * 1. output must not be null or empty
  24. * 2. input must not be null
  25. * 3. inputLen must be greater than or equal to 0
  26. */
  27. int base64_encode(char *output, char *input, int inputLen);
  28. /* base64_decode:
  29. * Description:
  30. * Decode a base64 encoded string into bytes
  31. * Parameters:
  32. * output: the output buffer for the decoding,
  33. * stores the decoded binary
  34. * input: the input buffer for the decoding,
  35. * stores the base64 string to be decoded
  36. * inputLen: the length of the input buffer, in bytes
  37. * Return value:
  38. * Returns the length of the decoded string
  39. * Requirements:
  40. * 1. output must not be null or empty
  41. * 2. input must not be null
  42. * 3. inputLen must be greater than or equal to 0
  43. */
  44. int base64_decode(char *output, char *input, int inputLen);
  45. /* base64_enc_len:
  46. * Description:
  47. * Returns the length of a base64 encoded string whose decoded
  48. * form is inputLen bytes long
  49. * Parameters:
  50. * inputLen: the length of the decoded string
  51. * Return value:
  52. * The length of a base64 encoded string whose decoded form
  53. * is inputLen bytes long
  54. * Requirements:
  55. * None
  56. */
  57. int base64_enc_len(int inputLen);
  58. /* base64_dec_len:
  59. * Description:
  60. * Returns the length of the decoded form of a
  61. * base64 encoded string
  62. * Parameters:
  63. * input: the base64 encoded string to be measured
  64. * inputLen: the length of the base64 encoded string
  65. * Return value:
  66. * Returns the length of the decoded form of a
  67. * base64 encoded string
  68. * Requirements:
  69. * 1. input must not be null
  70. * 2. input must be greater than or equal to zero
  71. */
  72. int base64_dec_len(char *input, int inputLen);
  73. #endif // _BASE64_H