Return-Path: william@bourbon.usc.edu Delivery-Date: Wed Nov 26 09:54:58 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id mAQHswxw026948 for ; Wed, 26 Nov 2008 09:54:58 -0800 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id mAQHrtHr026018 for ; Wed, 26 Nov 2008 09:53:55 -0800 Message-Id: <200811261753.mAQHrtHr026018@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: CS551: Final Project 2 : Delete Msg Date: Wed, 26 Nov 2008 09:53:55 -0800 From: Bill Cheng Someone wrote: > Any ideas on how do we convert unsigned char * to ASCII character array ? You mean from binary data (unsigned char *) to ASCII string (also unsigned char *)? To convert one byte of binary data to a string of length 2 in ASCII, you can do the following: void BinaryCharToTwoAsciiChars(unsigned char ch, unsigned char buf[2]) { unsigned char hi_nibble = ch >> 4; unsigned char lo_nibble = ch & 0x0f; switch (hi_nibble & 0x0f) { case 0x0: buf[0] = '0'; break; case 0x1: buf[0] = '1'; break; case 0x2: buf[0] = '2'; break; ... case 0xe: buf[0] = 'e'; break; case 0xf: buf[0] = 'f'; break; } switch (lo_nibble & 0x0f) { case 0x0: buf[1] = '0'; break; case 0x1: buf[1] = '1'; break; case 0x2: buf[1] = '2'; break; ... case 0xe: buf[1] = 'e'; break; case 0xf: buf[1] = 'f'; break; } } -- Bill Cheng // bill.cheng@usc.edu On Tue, Nov 25, 2008 at 11:11 PM, Bill Cheng wrote: > Someone wrote: > > > While sending the delete msg we have the format > > FileName=foo > > SHA1=63de... > > Nonce=fcca... > > Password=bac9... > > > > So we have to store all values as characters .. correct ? > > ASCII characters. > > > i.e the length of SHA1, Nonce and Password will be 40 bytes. > > 40 ASCII characters (which takes 40 bytes each to send). > > > and the total data part length will be > 120. > > Yes. > -- > Bill Cheng // bill.cheng@usc.edu