Skip to content

A C++ header-only hash algorithm library (including md5, sha1, sha256, sha224, sha384, sha512)

License

Notifications You must be signed in to change notification settings

Cra3z/cc_hashlib

Repository files navigation

cc_hashlib

import std;
import ccat.hashlib;

auto main() -> int {
    std::cout << ccat::hashlib::md5{}.update("Hello C++20 Modules").hexdigest(); // result: 113d5ad03d09b98cf4e22eb279bcdf8c
    return 0;
}

example/例子

  • Use this library only including the header hashlib
  • 仅需include头文件hashlib即可
#include "hashlib"
  • Get md5 of a string by using ccat::hash::md5
  • 使用ccat::hash::md5获取字符串的md5值
#include <iostream>
#include "hashlib"
auto main() ->int {
    ccat::hash::md5 m{"hello world"};
    std::cout << m.hexdigest() << '\n'; //result: 5eb63bbbe01eeed093cb22bb8f5acdc3
    return 0;
}
  • And also you can use the method update or operator<<
  • 你也可以使用updateoperator<<
#include <iostream>
#include "hashlib"
auto main() ->int {
    ccat::hash::md5 m{};
    m.update("hello world"); //or m.update("hello"); m.update(" world");
    std::cout << m.hexdigest() << '\n'; //result: 5eb63bbbe01eeed093cb22bb8f5acdc3
    return 0;
}
#include <iostream>
#include "hashlib"
auto main() ->int {
    ccat::hash::md5 m{};
    m << "hello world"; //or `m << "hello" << " world";`
    std::cout << m.hexdigest() << '\n'; //result: 5eb63bbbe01eeed093cb22bb8f5acdc3
    return 0;
}
  • Other hash algorithms are used in the same way as ccat::hash::md5
  • More hash algorithms will be supported in the future
  • 其它算法的用法与ccat::hash::md5相类似
  • 后续将支持更多哈希算法

About

A C++ header-only hash algorithm library (including md5, sha1, sha256, sha224, sha384, sha512)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages