Update some 2015 sources to .clang-tidy
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <openssl/evp.h>
|
||||
|
||||
using MD5Digest = unsigned char[EVP_MAX_MD_SIZE];
|
||||
using MD5Digest = std::array<unsigned char, EVP_MAX_MD_SIZE>;
|
||||
|
||||
unsigned int md5(MD5Digest digest, std::string const& s)
|
||||
auto md5(MD5Digest& digest, std::string const& s) -> unsigned int
|
||||
{
|
||||
EVP_MD const* md{EVP_md5()};
|
||||
unsigned int md_len;
|
||||
unsigned int md_len{0};
|
||||
|
||||
EVP_MD_CTX* md_ctxt{EVP_MD_CTX_new()};
|
||||
assert(md_ctxt != NULL);
|
||||
EVP_DigestInit_ex2(md_ctxt, md, NULL);
|
||||
EVP_DigestUpdate(md_ctxt, s.data(), s.length());
|
||||
EVP_DigestFinal_ex(md_ctxt, digest, &md_len);
|
||||
EVP_MD_CTX* md_context{EVP_MD_CTX_new()};
|
||||
assert(md_context != nullptr);
|
||||
EVP_DigestInit_ex2(md_context, md, nullptr);
|
||||
EVP_DigestUpdate(md_context, s.data(), s.length());
|
||||
EVP_DigestFinal_ex(md_context, digest.data(), &md_len);
|
||||
return md_len;
|
||||
}
|
||||
|
||||
bool is_valid(std::string const& s)
|
||||
auto is_valid(std::string const& s) -> bool
|
||||
{
|
||||
MD5Digest digest;
|
||||
auto len = md5(digest, s);
|
||||
@@ -29,7 +29,7 @@ bool is_valid(std::string const& s)
|
||||
return digest[0] == 0 && digest[1] == 0 && digest[2] == 0;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
auto main() -> int
|
||||
{
|
||||
for (std::string line; std::getline(std::cin, line);) {
|
||||
unsigned i = 0;
|
||||
|
Reference in New Issue
Block a user