aboutsummaryrefslogtreecommitdiff
path: root/src/md5.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/md5.cpp')
-rw-r--r--src/md5.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/md5.cpp b/src/md5.cpp
index c11bf2f..0cd4254 100644
--- a/src/md5.cpp
+++ b/src/md5.cpp
@@ -224,4 +224,30 @@ uint8_t* md5File(FILE *file){
uint32_t rotateLeft(uint32_t x, uint32_t n){
return (x << n) | (x >> (32 - n));
}
+
+char* md5sum(char* s) {
+ static char md5[64] = {0};
+ uint8_t* x = md5String(s);
+ memset(md5, 0x0, 64);
+ for (auto i = 0; i < 16; i++) {
+ sprintf(md5 + i * 2, "%02x", x[i]);
+ }
+ return md5;
+}
+
+int lead_zeros(char* s) {
+ char* p = s;
+ int total = 0;
+ while (*p != '\0') {
+ if (*p == '0') {
+ total += 1;
+ p++;
+ }
+ else {
+ break;
+ }
+ }
+ return total;
+}
+
}