Advertisement
FlyFar

libs/SHA256/sha256.h

Mar 24th, 2024
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | Cybersecurity | 0 0
  1. /*
  2. *   SHA-256 implementation.
  3. *
  4. *   Copyright (c) 2010 Ilya O. Levin, http://www.literatecode.com
  5. *
  6. *   Permission to use, copy, modify, and distribute this software for any
  7. *   purpose with or without fee is hereby granted, provided that the above
  8. *   copyright notice and this permission notice appear in all copies.
  9. *
  10. *   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. *   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. *   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. *   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. *   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. *   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. *   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifdef _MSC_VER
  19. #ifndef uint8_t
  20. typedef unsigned __int8 uint8_t;
  21. #endif
  22. #ifndef uint32_t
  23. typedef unsigned __int32 uint32_t;
  24. #endif
  25. #ifndef uint64_t
  26. typedef __int64 int64_t;
  27. typedef unsigned __int64 uint64_t;
  28. #endif
  29. #else
  30. #include <stdint.h>
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37.  
  38.    typedef struct {
  39.        uint32_t buf[16];
  40.        uint32_t hash[8];
  41.        uint32_t len[2];
  42.    } sha256_context;
  43.  
  44.    void sha256_init(sha256_context *);
  45.    void sha256_hash(sha256_context *, uint8_t * /* data */, uint32_t /* len */);
  46.    void sha256_done(sha256_context *, uint8_t * /* hash */);
  47.    void sha256(uint8_t *output, uint8_t *input, int inlen);
  48.  
  49. #ifdef __cplusplus
  50. }
  51. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement