473,786 Members | 2,775 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MD5 message digest conversion to 16 byte array

Hi ,

I have implemented MD5 in C language . I am getting an output of 32
bits Hexadecimal number . for example :

83a80d3ca057492 f0ce99ac1db8dce d0

I need to convert this string same to 16 byte array.
Can anyone help me ?

Thanks a lot !!!
Chaitali

Jun 26 '06 #1
11 5280
ch***********@g mail.com wrote:
Hi ,

I have implemented MD5 in C language . I am getting an output of 32
bits Hexadecimal number . for example :

83a80d3ca057492 f0ce99ac1db8dce d0
That's not a 32-bit hexadecimal number by any interpretation of that phrase;
that's a string.
I need to convert this string same to 16 byte array.
If you actually implemented MD5, it's not likely that you want this. You can
change the code that produces the string above to output a byte array instead.

If, on the other hand, you're writing a function that has to take a string
like this and turn it into a byte array, that's a different matter.
Can anyone help me ?

Since your question does not appear to involve anything that's C specific
and doesn't include any code, it's rather hard to help you.

MD5 is a very common algorithm. Have you tried checking whether Google is
your friend in this case?

S.
Jun 26 '06 #2
Thanks .
Sorry for putting an incomplete question .
Actually you are right . I need to convert this string to byte array .
Can you help me how to convert the string into byte array because I
think there is some padding issues involved in the conversion,

Skarmander wrote:
ch***********@g mail.com wrote:
Hi ,

I have implemented MD5 in C language . I am getting an output of 32
bits Hexadecimal number . for example :

83a80d3ca057492 f0ce99ac1db8dce d0

That's not a 32-bit hexadecimal number by any interpretation of that phrase;
that's a string.
I need to convert this string same to 16 byte array.


If you actually implemented MD5, it's not likely that you want this. You can
change the code that produces the string above to output a byte array instead.

If, on the other hand, you're writing a function that has to take a string
like this and turn it into a byte array, that's a different matter.
Can anyone help me ?

Since your question does not appear to involve anything that's C specific
and doesn't include any code, it's rather hard to help you.

MD5 is a very common algorithm. Have you tried checking whether Google is
your friend in this case?

S.


Jun 26 '06 #3
ch***********@g mail.com wrote:
Thanks .
Sorry for putting an incomplete question .
Actually you are right . I need to convert this string to byte array .
Can you help me how to convert the string into byte array because I
think there is some padding issues involved in the conversion,

Skarmander wrote:
ch***********@g mail.com wrote:
Hi ,

I have implemented MD5 in C language . I am getting an output of 32
bits Hexadecimal number . for example :

83a80d3ca057492 f0ce99ac1db8dce d0

That's not a 32-bit hexadecimal number by any interpretation of that phrase;
that's a string.
I need to convert this string same to 16 byte array.

If you actually implemented MD5, it's not likely that you want this. You can
change the code that produces the string above to output a byte array instead.

If, on the other hand, you're writing a function that has to take a string
like this and turn it into a byte array, that's a different matter.
Can anyone help me ?

Since your question does not appear to involve anything that's C specific
and doesn't include any code, it's rather hard to help you.

MD5 is a very common algorithm. Have you tried checking whether Google is
your friend in this case?

S.


There are may ways.
one is to make the array 0123456789ABCDE ( match the case to you input)

start from the MSD find the char in the array add the position to total.
mult by 16 and move to the next digit.

Starting from the LSD you will need to use a multiplier variable.
Jun 26 '06 #4
ch***********@g mail.com writes:
Thanks .
Sorry for putting an incomplete question .
Actually you are right . I need to convert this string to byte array .
Can you help me how to convert the string into byte array because I
think there is some padding issues involved in the conversion,

I find it extremely difficult to believe that you've been able to
(correctly) implement the MD5 algorithm, but are unable to convert a
string input to a byte array. Anyway, I could be wrong, so, good luck
with your problem.

--
Chris.
Jun 26 '06 #5

Chris McDonald wrote:
ch***********@g mail.com writes:
Thanks .
Sorry for putting an incomplete question .
Actually you are right . I need to convert this string to byte array .
Can you help me how to convert the string into byte array because I
think there is some padding issues involved in the conversion,

I find it extremely difficult to believe that you've been able to
(correctly) implement the MD5 algorithm, but are unable to convert a
string input to a byte array. Anyway, I could be wrong, so, good luck
with your problem.


Are you <SHOCK> suggesting that they randomly picked up code off the
web and pasted it into their application without really knowing what
they are doing?

It's almost as if people should write pre-packaged bodies, if not in
the form of a library, of cryptographic algorithms and protocols for
just such an occasion. That it should ALSO be accessible by some form
of web page searching function, almost like a web search.

:-)

Tom

Jun 26 '06 #6
ch***********@g mail.com wrote:
Skarmander wrote:
ch***********@g mail.com wrote:
Hi ,

I have implemented MD5 in C language . I am getting an output of 32
bits Hexadecimal number . for example :

83a80d3ca057492 f0ce99ac1db8dce d0

That's not a 32-bit hexadecimal number by any interpretation of that phrase;
that's a string.
I need to convert this string same to 16 byte array.

If you actually implemented MD5, it's not likely that you want this. You can
change the code that produces the string above to output a byte array instead.

If, on the other hand, you're writing a function that has to take a string
like this and turn it into a byte array, that's a different matter.
Can anyone help me ?

Since your question does not appear to involve anything that's C specific
and doesn't include any code, it's rather hard to help you.

MD5 is a very common algorithm. Have you tried checking whether Google is
your friend in this case?


Thanks .
Sorry for putting an incomplete question .
Actually you are right . I need to convert this string to byte array .
Can you help me how to convert the string into byte array because I
think there is some padding issues involved in the conversion,

Don't top-post, please. Put your reply at the bottom.

There are no padding issues involved if you are always converting an even
number of hexadecimal digits into a contiguous sequence of bytes.

The function you'll be writing will look something like this:

void hexstring_to_by tes(const char *str, unsigned char *bytes, size_t
len) {
size_t n;
for (n = 0; n < len; n += 2) {
bytes[n / 2] = hexdigit_to_int (str[n]) * 16 +
hexdigit_to_int (str[n + 1]);
}
}

Figuring out how to properly call this function and writing
hexdigit_to_int () are left as exercises. Also, think about how to handle
improper input.

S.
Jun 26 '06 #7
ch***********@g mail.com wrote:
Thanks .


Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the other 99% of the posts in this
group.


Brian

Jun 26 '06 #8
Tom St Denis wrote:
Chris McDonald wrote:
ch***********@g mail.com writes:
Thanks .
Sorry for putting an incomplete question .
Actually you are right . I need to convert this string to byte array .
Can you help me how to convert the string into byte array because I
think there is some padding issues involved in the conversion,

I find it extremely difficult to believe that you've been able to
(correctly) implement the MD5 algorithm, but are unable to convert a
string input to a byte array. Anyway, I could be wrong, so, good luck
with your problem.


Are you <SHOCK> suggesting that they randomly picked up code off the
web and pasted it into their application without really knowing what
they are doing?

It's almost as if people should write pre-packaged bodies, if not in
the form of a library, of cryptographic algorithms and protocols for
just such an occasion. That it should ALSO be accessible by some form
of web page searching function, almost like a web search.

:-)

Tom


I had tried everything . But it didn't work .
That's why thought of asking help .
anyway .. now i think i shouldn't have .

Jun 27 '06 #9

Skarmander wrote:
ch***********@g mail.com wrote:
Skarmander wrote:
ch***********@g mail.com wrote:
Hi ,

I have implemented MD5 in C language . I am getting an output of 32
bits Hexadecimal number . for example :

83a80d3ca057492 f0ce99ac1db8dce d0

That's not a 32-bit hexadecimal number by any interpretation of that phrase;
that's a string.

I need to convert this string same to 16 byte array.
If you actually implemented MD5, it's not likely that you want this. You can
change the code that produces the string above to output a byte array instead.

If, on the other hand, you're writing a function that has to take a string
like this and turn it into a byte array, that's a different matter.

Can anyone help me ?

Since your question does not appear to involve anything that's C specific
and doesn't include any code, it's rather hard to help you.

MD5 is a very common algorithm. Have you tried checking whether Google is
your friend in this case?


> Thanks .
> Sorry for putting an incomplete question .
> Actually you are right . I need to convert this string to byte array .
> Can you help me how to convert the string into byte array because I
> think there is some padding issues involved in the conversion,
>

Don't top-post, please. Put your reply at the bottom.

There are no padding issues involved if you are always converting an even
number of hexadecimal digits into a contiguous sequence of bytes.

The function you'll be writing will look something like this:

void hexstring_to_by tes(const char *str, unsigned char *bytes, size_t
len) {
size_t n;
for (n = 0; n < len; n += 2) {
bytes[n / 2] = hexdigit_to_int (str[n]) * 16 +
hexdigit_to_int (str[n + 1]);
}
}

Figuring out how to properly call this function and writing
hexdigit_to_int () are left as exercises. Also, think about how to handle
improper input.

S.


Thanks for your help . :-)

Jun 27 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3798
by: CAFxX | last post by:
i'm writing a program that executes some calculations on a bitmap loaded in memory. these calculation ends up with pixel wth values far over 255, but i need them to be between 0 and 255 since i got to write them in a bmp file (in which RGB values are limited to 8 bits per channel). so i need to have them scaled down. first of all i find the highest and lowest of those values:(keep in mind that max, min, bmp, ptr are ulong and w, h are...
5
3360
by: john | last post by:
Here is the short story of what i'm trying to do. I have a 4 sided case labeling printer setting out on one of our production lines. Now then i have a vb.net application that sends data to this printer using a RawPrinterHelper class that i found I believe in the msdn. the class works wonderfully when I send stright text data (in the correctly formated string that the sato printer requires.) but when i go to send a image nothing is...
1
7772
by: Jim Shank | last post by:
I am adding support to my application for Oracle 10g and using Enterprise Library Data Access Application Blocks and trying to determine the best way to convert the GUID's which are stored as RAW(16) in Oracle (Byte Arrays) back to GUID's in my data layer. My best guess is a conversion method that the DataSet goes through before leaving the data access layer. Here is my code: Private Sub Raw16ToGuid(ByRef dataSet As DataSet) Dim...
15
2560
by: C# Learner | last post by:
Hi, I have a string (System.String) which holds some data. This data is encoding in UTF8 (i.e. anywhere in the string where there should be a single 'é' character, there will be two characters holding the equivalent of that character in the UTF8 format). How can I decode this UTF8-encoded string? In Delphi I could simple say:
2
4648
by: iyuen | last post by:
I'm trying to convert byte array (valid bitmap format) into some bitmaps and back to byte array again. But when I inspect the content of the array before and after the conversion they are different. I'm used the following code to do the conversion. May any of you tell me what's happening? Thanks, Here are my code.... internal static Bitmap convertImage(string imageText)
5
1316
by: Jim Hubbard | last post by:
I have some C# code that is supposed to wrap the defrag APIs and I am trying to convert it to VB.Net (2003). But, I keep having problems. The C# code is relatively short, so I'll post it here..... -------- // // a set of simple C# wrappers over the NT Defragmenter APIs //
0
319
by: chaitali.pats | last post by:
Hi , I have implemented MD5 in C language . I am getting an output of 32 bits Hexadecimal number . for example : 83a80d3ca057492f0ce99ac1db8dced0 I need to convert this string to 16 byte array. Can anyone help me ?
5
9042
by: Jamie Risk | last post by:
This is the code snippet that I've come up to convert a byte to string. Is there a best practiced method for such a conversion? - Jamie public static string ByteArrayToString(byte array) { if (null == array || 0 == array.Length) { throw new NullReferenceException();
0
1554
by: cooljoel27 | last post by:
can any one of youll write a code in microsoft Visual basics for secure Hash algorithm please see additional information below (this is for my final year project) ALGORITHM  Append padding bits : The message length should be congruent to 448 mod 512.Padding is always added even if the msg is already of the desired length.Padding consists of a single 1-bit followed by the necessary number of 0-bits.  Append length : A block of 64-bits is...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.