Convert string to hex.
2012-04-13
170 words
1 min read
If you want to use snoop or tcpdump with advanced search in the packet, then you would need to convert the string to hex string. For this, either you can use a web search and find some web application to do that or you can use a simple C program like this π
/* * ===================================================================================== * * Filename: ascii.c * * Description: ascii to dec * * Version: 1.0 * Ceated: 03/02/2012 12:08:49 PM * Revision: none * Compiler: gcc * * Author: Amit Agarwal (aka), amit.agarwal@roamware.com * Last modified: Thu Mar 08, 2012 08:47PM * * ===================================================================================== */ void main (int argc, char **argv){ int i=0; char a[200]="",b[200]=""; printf("String - %s, Length - %d\n",argv[1],strlen(argv[1])); /*printf("%x\n 0x",argv[1]);*/ while (i < strlen(argv[1])){ /*printf("%c",argv[1][i]);*/ sprintf(a,"%s%x",a,argv[1][i]); /*printf("a=%s\n",a); printf("b=%s\n",b);*/ sprintf(b,"%s%d",b,argv[1][i]); i++; } printf ("\n"); printf ("String : %s\n",argv[1]); printf ("Hex : 0x%s\n", a); printf ("Dec : %s\n", b); }
Related articles
- Re: iis bug (seclists.org)
- Problem of file transfer in socket programming (daniweb.com)
- [Unix C] ECHO Implementation (jetcracker.wordpress.com)
- Character Stuffing in C (sourcecode4all.wordpress.com)
Related Articles:
- 2011/11/28 Linux hardware details.
- 2012/02/21 glances β Get a glimpse of the whole system
- 2012/02/15 Get yourself som new themes for vim
- 2012/02/09 Tora installation on Fedora 16 with rpm
- 2012/02/06 tora on Fedora 16 for mysql and Oracle.
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.