Add .clang-format and apply it

This commit is contained in:
2021-12-02 07:18:16 +00:00
parent e58dede1b6
commit cd5e2538df
103 changed files with 2714 additions and 2132 deletions

View File

@@ -8,26 +8,29 @@
using MD5Digest = unsigned char[EVP_MAX_MD_SIZE];
unsigned int md5(MD5Digest digest, std::string const &s) {
EVP_MD const* md{EVP_md5()};
unsigned int md_len;
unsigned int md5(MD5Digest digest, std::string const& s)
{
EVP_MD const* md{EVP_md5()};
unsigned int md_len;
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);
return md_len;
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);
return md_len;
}
bool is_valid(std::string const &s) {
bool is_valid(std::string const& s)
{
MD5Digest digest;
auto len = md5(digest, s);
assert(len >= 3);
return digest[0] == 0 && digest[1] == 0 && (digest[2] & 0xf0) == 0;
}
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
for (std::string line; std::getline(std::cin, line);) {
unsigned i = 0;
while (!is_valid(line + std::to_string(i))) {