#include "auth/crypto.hpp" #include #include #include #include namespace wowee { namespace auth { std::vector Crypto::sha1(const std::vector& data) { std::vector hash(SHA_DIGEST_LENGTH); SHA1(data.data(), data.size(), hash.data()); return hash; } std::vector Crypto::sha1(const std::string& data) { std::vector bytes(data.begin(), data.end()); return sha1(bytes); } std::vector Crypto::md5(const std::vector& data) { std::vector hash(MD5_DIGEST_LENGTH); unsigned int length = 0; EVP_Digest(data.data(), data.size(), hash.data(), &length, EVP_md5(), nullptr); return hash; } std::vector Crypto::md5(const std::string& data) { std::vector bytes(data.begin(), data.end()); return md5(bytes); } std::vector Crypto::hmacSHA1(const std::vector& key, const std::vector& data) { std::vector hash(SHA_DIGEST_LENGTH); unsigned int length = 0; HMAC(EVP_sha1(), key.data(), key.size(), data.data(), data.size(), hash.data(), &length); return hash; } } // namespace auth } // namespace wowee