1
0

xxtea.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /***********************************************************************
  2. Copyright 2006-2009 Ma Bingyao
  3. Copyright 2013 Gao Chunhui, Liu Tao
  4. These sources is free software. Redistributions of source code must
  5. retain the above copyright notice. Redistributions in binary form
  6. must reproduce the above copyright notice. You can redistribute it
  7. freely. You can use it with any free or commercial software.
  8. These sources is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY. Without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. github: https://github.com/liut/pecl-xxtea
  12. *************************************************************************/
  13. #ifndef XXTEA_H
  14. #define XXTEA_H
  15. #include <stddef.h> /* for size_t & NULL declarations */
  16. #if defined(_MSC_VER)
  17. typedef unsigned __int32 xxtea_long;
  18. #else
  19. #if defined(__FreeBSD__) && __FreeBSD__ < 5
  20. /* FreeBSD 4 doesn't have stdint.h file */
  21. #include <inttypes.h>
  22. #else
  23. #include <stdint.h>
  24. #endif
  25. typedef uint32_t xxtea_long;
  26. #endif /* end of if defined(_MSC_VER) */
  27. #define XXTEA_MX (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z)
  28. #define XXTEA_DELTA 0x9e3779b9
  29. unsigned char *xxtea_encrypt(unsigned char *data, xxtea_long data_len, unsigned char *key, xxtea_long key_len, xxtea_long *ret_length);
  30. unsigned char *xxtea_decrypt(unsigned char *data, xxtea_long data_len, unsigned char *key, xxtea_long key_len, xxtea_long *ret_length);
  31. #endif