Easy to use SHA256 and SHA512 functions.

GitOrigin-RevId: f1d959e2ab69e7e176e705d16f05546a7ef33399
This commit is contained in:
levlam 2018-08-10 02:35:07 +03:00
parent 73aa76dc5f
commit f92e25fcd9
2 changed files with 16 additions and 0 deletions

View File

@ -359,6 +359,18 @@ void sha512(Slice data, MutableSlice output) {
CHECK(result == output.ubegin());
}
string sha256(Slice data) {
string result(32, '\0');
sha256(data, result);
return result;
}
string sha512(Slice data) {
string result(64, '\0');
sha512(data, result);
return result;
}
struct Sha256StateImpl {
SHA256_CTX ctx;
};

View File

@ -64,6 +64,10 @@ void sha256(Slice data, MutableSlice output);
void sha512(Slice data, MutableSlice output);
string sha256(Slice data) TD_WARN_UNUSED_RESULT;
string sha512(Slice data) TD_WARN_UNUSED_RESULT;
struct Sha256StateImpl;
struct Sha256State {