# Check if a string match a (bcrypt) hash 2023-05-04T16:55:17Z ``` /* * Description: Check if a hash match a string * Version: 0.1 * Licence: MIT * Author: Xavier Cartron prx@si3t.ch */ #include #include #include #include #include #include /* compare password passed on stdin with hash passed as argv[2] */ int main(int argc, char *argv[]) { char pw[LINE_MAX] = {'\0'}; if (argc != 2) errx(1, "usage: printf \"pw\" | %s ", argv[0]); if (fgets(pw, LINE_MAX, stdin) == NULL) err(1, "fail to read from stdin"); pw[strcspn(pw, "\n")] = '\0'; /* remove ending \n if any */ if (crypt_checkpass(pw, argv[1]) != 0) return 1; printf("match \\o/\n"); return 0; } ``` gemini://si3t.ch/log/2023-05-04-Check-if-a-string-match-a--bcrypt--hash.txt

-- Leo's gemini proxy

-- Connecting to si3t.ch:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/plain

-- Response ended

-- Page fetched on Fri May 17 09:34:34 2024