apikey.cpp 673 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "main.h"
  2. /////////////////////////////////////////////////////////////////////////////
  3. CApiKeys::CApiKeys(void)
  4. {
  5. }
  6. CApiKeys::~CApiKeys(void)
  7. {
  8. }
  9. void CApiKeys::PushKey(const API_KEY &rak)
  10. {
  11. m_apiKeys.push_back(rak);
  12. }
  13. bool CApiKeys::Sha256HashString(const char *pszString, char *pszDigest, size_t nCChDigest)
  14. {
  15. if(!pszString || !pszDigest || (nCChDigest < SHA256_DIGEST_LENGTH))
  16. return false;
  17. SHA256_CTX context;
  18. if(!SHA256_Init(&context))
  19. return false;
  20. if(!SHA256_Update(&context, pszString, strlen(pszString)))
  21. return false;
  22. if(!SHA256_Final((unsigned char*)pszDigest, &context))
  23. return false;
  24. return true;
  25. }