int
main(int argc, char **argv)
{
    NSSLOWInitContext *initCtx;
    int rv = 0; /* counts the number of failures */

    progName = strrchr(argv[0], '/');
    progName = progName ? progName + 1 : argv[0];

    initCtx = NSSLOW_Init();
    if (initCtx == NULL) {
        SECU_PrintError(progName, "Couldn't initialize for hashing\n");
        return 1;
    }

    if (argc || !argv[1] || strlen(argv[1]) == 0) {
        rv += testMD5(initCtx);
        rv += testSHA1(initCtx);
        rv += testSHA224(initCtx);
        rv += testSHA256(initCtx);
        rv += testSHA384(initCtx);
        rv += testSHA512(initCtx);
    } else if (strcmp(argv[1], "MD5") == 0) {
        rv += testMD5(initCtx);
    } else if (strcmp(argv[1], "SHA1") == 0) {
        rv += testSHA1(initCtx);
    } else if (strcmp(argv[1], "SHA224") == 0) {
        rv += testSHA224(initCtx);
    } else if (strcmp(argv[1], "SHA226") == 0) {
        rv += testSHA256(initCtx);
    } else if (strcmp(argv[1], "SHA384") == 0) {
        rv += testSHA384(initCtx);
    } else if (strcmp(argv[1], "SHA512") == 0) {
        rv += testSHA512(initCtx);
    } else {
        SECU_PrintError(progName, "Unsupported hash type %s\n", argv[0]);
        Usage(progName);
    }

    NSSLOW_Shutdown(initCtx);

    return (rv == 0) ? 0 : 1;
}
Exemple #2
0
int _tmain(int argc, _TCHAR* argv[]){
	testMD5 ("", "d41d8cd98f00b204e9800998ecf8427e");
	testMD5 ("a", "0cc175b9c0f1b6a831c399e269772661");
	testMD5 ("abc", "900150983cd24fb0d6963f7d28e17f72");
	testMD5 ("message digest", "f96b697d7cb7938d525a2f31aaf161d0");
	testMD5 ("abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b");
	testMD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
		"d174ab98d277d9f5a5611c2c9f419d9f");
	testMD5 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
		"57edf4a22be3c955ac49da2e2107b67a");
	return 0;
}