Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9245853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:21:29+00:00 2026-06-18T09:21:29+00:00

am trying to implement an application that uses an MD5 hash underneath, i have

  • 0

am trying to implement an application that uses an MD5 hash underneath, i have acquired the MD5 hash program from the internet, but i don’t know how to pass the string from my program ( my program written in C) to the program that calculate the MD5 hash.

this is the main of the program that calculate the MD5 hash..

//
// MD5 Hashing Example - Using Windows Crypto API
//
// by Napalm @ NetCore2K
//
#include <stdio.h>
#include <string.h>
#include "winmd5.h"
HCRYPTPROV hCryptProv;

int main(int argc, char *argv[])
{
    int i;
    CryptStartup();
    if(argc > 1){
        MD5Context ctx;
        MD5Init(&ctx);
        MD5Update(&ctx, (unsigned char *)argv[1], strlen(argv[1]));
        MD5Final(&ctx);
        for(i = 0; i < 16; i++)
            printf("%02x", ctx.digest[i]);
        printf("\n");
    }else
        printf("Usage: %s <string>\n", argv[0]);
    CryptCleanup();
    return 0;
}

this is the header file content..

//
// MD5 Hashing Example - Using Windows Crypto API
//
// by Napalm @ NetCore2K
//
#include <windows.h>
#include <wincrypt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern HCRYPTPROV hCryptProv;

void PrintMD5(const char *);

typedef struct {

unsigned char digest[16];
unsigned long hHash;
} MD5Context;
BOOL CryptStartup()
{


if(CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET) == 0){
    if(GetLastError() == NTE_EXISTS){
    if(CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, 0) == 0){
            return FALSE;
        }   
    }
    else return FALSE;
}
return TRUE;
}
void CryptCleanup()
{
if(hCryptProv) CryptReleaseContext(hCryptProv, 0);
hCryptProv = NULL;
}
void inline MD5Init(MD5Context *ctx)
{ 
CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &ctx->hHash);
}
void inline MD5Update(MD5Context *ctx, unsigned char const *buf, unsigned len)
{
CryptHashData(ctx->hHash, buf, len, 0);
}
void inline MD5Final(MD5Context *ctx)
{
DWORD dwCount = 16;
CryptGetHashParam(ctx->hHash, HP_HASHVAL, ctx->digest, &dwCount, 0);
if(ctx->hHash) CryptDestroyHash(ctx->hHash);
ctx->hHash = 0;
}
void PrintMD5(const char *s)
{
MD5Context ctx;
MD5Init(&ctx);
MD5Update(&ctx, (const unsigned char *)s, strlen(s));
MD5Final(&ctx);

int i;
for (i = 0; i < 16; i++) {
    printf("%02x", ctx.hHash[i]);
}

printf("\n");
 }

how should i call this Main(), and how to pass the String to it and get the result.?
thanks in advance.

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:21:30+00:00Added an answer on June 18, 2026 at 9:21 am

    You don’t call main() again. You rather use this program as an example to write a separate function, like this:

    void PrintMD5(const char *s)
    {
        MD5Context ctx;
        MD5Init(&ctx);
        MD5Update(&ctx, (const unsigned char *)s, strlen(s));
        MD5Final(&ctx);
    
        int i;
        for (i = 0; i < 16; i++) {
            printf("%02x", ctx.digest[i]);
        }
    
        printf("\n");
    }
    

    Then you can call this from your own program like:

    PrintMD5("FooBarHelloWorld42");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement an application that uses AdaBoost algorithm. I know that
I am trying to debug an embedded application that uses select() to implement communication
I'm trying to implement drag and drop functionality in a Surface Application that is
We are trying to implement the Microsoft Sync Framework into our application that persists
I'm trying to implement a rails application with neo4j. For hosting I found that
I am trying to implement a view similar to that of Apple's calendar application's
I am trying to implement an application which uses RIOT (Radical Image Optimization Tool)
I am trying to build a core application that uses plugins so that the
I have some web application that uses jQuery to send AJAX requests to server.
I am trying to implement a browser-like little application that would allow me to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.