- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Problem running c program calling md5_string funct...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2005 07:47 PM
10-26-2005 07:47 PM
desar# cc md.c -o md -lcryptx
desar# ./md hola
Error: Cannot hash string hola
desar#
1 #include
2 #include
3 #include
4
5 off_t md5_string(unsigned char *bufp, off_t len, unsigned char digest[])
;
6
7 void obtener_md5 (unsigned char *my_string, off_t my_len)
8 {
9 unsigned char my_digest[MD5_HSIZE];
10 int i = 0;
11
12 if ((md5_string(my_string, my_len, my_digest)) < 0) {
13 printf ("Error: Cannot hash string %s\n",my_string );
14 return;
15 }
16
17 for (i = 0; i < MD5_HSIZE; i++) printf("%02x", my_digest[i] );
18 }
19
20
21 int main(int argc, unsigned char **argv)
22 {
23 unsigned char *my_string;
24 unsigned char my_digest[MD5_HSIZE];
25 off_t my_len;
26 int i = 0;
27
28 if (argc != 2)
29 {
30 fprintf(stderr, "Uso: md cadena\n");
31 exit(2);
32 }
33
34 my_string = argv[1];
35
36 if ((md5_string(my_string, my_len, my_digest)) < 0) {
37 printf ("Error: Cannot hash string %s\n",my_string );
38 exit(1);
39 }
40
41 printf ("Hash md5 de la cadena %s de longitud %i :\n",my_string, my_le
n);
42 for (i = 0; i < MD5_HSIZE; i++) printf("%02x", my_digest[i] );
43 printf ("\n");
44 exit(0);
45 }
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2005 07:58 PM
10-26-2005 07:58 PM
Re: Problem running c program calling md5_string function
desar:/# uname -a
HP-UX desar B.11.11 U 9000/800 4221864724 unlimited-user license
desar:/# swlist -l product | grep MD5
LibCryptX A.01.00.00 HP-UX LibCryptX (MD5 APIs)
MD5sum A.01.00.00 HP-UX MD5sum (md5sum Command)
Sample runnning "md5sum" command:
desar:/# echo "hola\c" | md5sum -k
4d186321c1a7f0f354b297e8914ab240 4
desar:/#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2005 08:52 PM
10-26-2005 08:52 PM
Re: Problem running c program calling md5_string function
34 my_string = argv[1];
35 my_len = strlen(my_string);
36 if ((md5_string(my_string, my_len, my_digest)) < 0) {
37 printf ("Error: Cannot hash string %s\n",my_string );
38 exit(1);
Would that help? I don't have the man page for md5_string, so I'm guessing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2005 11:13 PM
10-26-2005 11:13 PM
Re: Problem running c program calling md5_string function
Man page says "my_len" is an output parameter:
The md5_string() function hashes an arbitrary finite stream of data (similar to the example in the preceding paragraph). It returns the digest in the output parameter and the string size as a return argument.
I attach Md5 man pages.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2005 04:25 AM
10-27-2005 04:25 AM
Re: Problem running c program calling md5_string function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2005 10:06 AM
10-27-2005 10:06 AM
SolutionAfter including Stephen's suggestion in your code i.e.
>> my_len = strlen(my_string); <<
compile your program in 64-bit mode by supplying the +DD64 switch...
# cc +DD64 md.c -o md -lcryptx
For 32-bit compilation replace md5_string() routine with the 32-bit primitives i.e.
md5_init()
md5_update()
md5_final()
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2005 11:12 AM
10-27-2005 11:12 AM
Re: Problem running c program calling md5_string function
Attached is the code for the "md" program that uses the core 32-bit APIs i.e.
md5_init()
md5_update()
md5_final()
It'll run on both 32 and 64-bit machines. However the md5-string() function needs to be compiled in 64-bit mode.
Hope it helps...Enjoy!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2005 06:20 PM
10-27-2005 06:20 PM
Re: Problem running c program calling md5_string function
Both solutions work fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2005 06:22 PM
10-27-2005 06:22 PM