Click here to Skip to main content
Click here to Skip to main content

Message Digest Application

By , 30 Mar 2004
Rate this:
Please Sign up or sign in to vote.

Introduction

This is class which generates the Message Digest using Various algorithms. It gives support to various algorithms such as MD4 - both 128 bits and 256 bits, MD5, RIPEMD-128, RIPEMD-160, RIPEMD-256, RIPEMD-320, SHA-1, SHA-256, SHA-384, SHA-512, HAVAL SERIES and BASE 64 Encoding and Decoding.

Using the code

This one program can be used for various purpose

  1. You can create the .dll file and can use it
  2. You can create the .exe file and use it as Console Based Utility

For creating the Console based utility

  • Include all the files except the MessageDigest.def file
  • Compile Main.cpp in VC++ 6.0 and then run it

Note:- Please remove all the files from the build expect the Main.cpp while you are creating the Console based utility.

Help is included in the Main.cpp or you can run the .exe file with parameters as (NULL, -?, -help)

For creating the dll file

Include the file MessageDigest.def file and remove the main.cpp, main.h, system.h files. Then compile the "Export.cpp" and build the MessageDigest.dll

//This is the Structure of Class which will do Everything

class Signature_Context
{

private:
  UCHAR ucCur_Size_of_Buffer;
  UCHAR ucCheck;
  UCHAR ucSignature_Type;
  UCHAR ucDigest_Length;

  DOUBLE dProgress,dDelta_Progress;
  Progress ShowProgress;

  union
  {
    FILE * OutFileStream;
    PCHAR  lpChar;
  }OutPut;

  union Finger_Prints
  {
    ULONGLONG ullValues[8];
    ULONG     ulValues[16];
    UINT    uiValues[32];
    UCHAR     ucValues[64];
    UCHAR    ucullValues[8][8];
    UCHAR    uculValues[16][4];
  }Hash;
  
  struct
  {
    UCHAR ucBlockSize;
    union
    {
      PUCHAR     ucValues;
      PSHORT     sValues;
      PULONG     ulValues;
      PULONGLONG ullValues;
    }Block;
  }Message;

  union
  {
    ULONGLONG ullLength;
    UCHAR ucChar_Codes[8];
    struct
    {
      unsigned Bit_4:6;
      unsigned Bit_3:6;
      unsigned Bit_2:6;
      unsigned Bit_1:6;
    }Bits;
  }Code_Convertor;

  // Private Functions
  LONG Initialize(UCHAR,UCHAR);
  VOID Destroy(VOID);

  LONG Expected_FileSize(ULONGLONG &);

  VOID MD4_Transform(VOID);
  VOID MD5_Transform(VOID);
  VOID SHA1_Transform(VOID);
  VOID SHA256_Transform(VOID);
  VOID SHA_384_512_Transform(VOID);
  VOID RIPEMD_128_256_Transform(VOID);
  VOID RIPEMD_160_320_Transform(VOID);
  VOID HAVAL_Transform(SHORT);

  VOID HAVAL_Tailor(VOID);

  VOID Signature_Transform(UCHAR);

  VOID Signature_Final(UCHAR);

  VOID BASE64_Encode_Update(PCHAR,ULONG &);
  VOID Base64_Encode_Final(VOID);
  VOID BASE64_Decode(PCHAR);

public:
  Signature_Context(UCHAR = MD_5, UCHAR = 0); // Parameterized Constructor
  ~Signature_Context(VOID); // Destructor

  LONG Create_Signature(PCHAR,ULONG,PCHAR,SHORT,
         UCHAR = 3,UCHAR = 0,SHORT = 0,  
             LONG = NULL,LONG = NULL);

  VOID Signature_Update(PCHAR,ULONG &);
};

Points of Interest

  1. Special Logic has been developed for Base 64 encoding and decoding
  2. A some what different implementation for calculating the Message Digest
  3. In all 16 Message Digest algorithms are supported
  4. Given support to MD4 256 bit algorithm, which require 2 copies of code running parallelly
  5. Implementation of AppendChunk method which will take in some extra input while processing (Not in Console Based)
  6. The program gives back the progress of transformation (Not in Console Based)

Special Logic used for BASE 64 Encoding and Decoding.

I had used the concept of bit datatype. Check out the cool code and also the speed which i had reduced for calculation of BASE 64 Encoding and Decoding

I wonder "Why people use the shifting logic when they had Bit Data type Which gradually increases the Execution time"

An efficient use of CALLBACK from C++

Lastly, I would like to thank Respected Sir, Shyam R. Soni for his priceless guidance through out this project. It would be never be possible without him. I would also like to thanks Dominik Reichl for his very valuable tips and guidance

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Shinde Vikram V.
Web Developer
India India
No Biography provided

Comments and Discussions

 
GeneralUsefull PinmemberCem Kalyoncu16-Aug-06 23:20 
GeneralCompiler Errors Pinmemberivax3-Oct-05 23:13 
GeneralRe: Compiler Errors PinmemberCem Kalyoncu16-Aug-06 23:13 
GeneralMD4 -> little question... Pinmemberdghhngd4522-Sep-04 0:58 
GeneralRe: MD4 -> little question... PinmemberShinde Vikram23-Sep-04 17:31 
GeneralRe: MD4 -> little question... Pinmemberdghhngd4523-Sep-04 22:15 
GeneralRe: MD4 -> little question... PinsussAnonymous24-Sep-04 4:45 
GeneralRe: MD4 -> little question... PinmemberShinde Vikram24-Sep-04 18:49 
GeneralRe: MD4 -> little question... PinsussAnonymous25-Sep-04 10:12 
Generalplz give me suggestions PinmemberShinde Vikram8-Apr-04 7:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 31 Mar 2004
Article Copyright 2004 by Shinde Vikram V.
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid