hi!
Use String.Format to created a formatted string, using "2x" in the format
specifier, to suit your need.
--
"I can't be Garbage Collected... I am pinned to .NET"
Kumar Gaurav Khanna
Microsoft MVP - .NET | Early Achiever MCSE Windows 2000 | MCSE NT 4.0 |
MCP+I
WWW: http://www.wintoolzone.com/
> Hi Annamalai,
> When I encrypt my input using Crypto Service Provide, it returns a byte
> array (length = 16). now i need to convert it to a string which contains
the
> hex representation of these bytes. This means there'll be 32 hex
characters
> representing these 16 bytes. My question is, How to get sucha string.
> If I use UnicodeEncoder.GetString(byte[]), it returns a string containing
8
> Unicode charatcters. How to get a string containing 32 chaarteres (every
two
> character being a hex representation of a byte).
> Regards
> - Mrinal
> > Hi,
> > You Decode the string before displaying to the user.
> > Regards,
> > S.Annamalai.
> > > Hey,
> > > Thanks Deepak, Vladimir. Thatz a neat solution.
> > > Just the other side of the coin. the byte arry that i get after
> encryption
> > > has to be converted back to string. now, there is a GetString method
in
> > > unicodeEncoding class that accepts byte array. the trouble is
encryption
> > > results in some hex data. When I display this as String, it's
> unreadable.
> > > How to get wround this problem?
> > > Thanks once again for the quick response.
> > > Regards
> > > - Mrinal
> > > > Hi,
> > > > I'm surprised to find that I don't have an answer to this seemingly
> > > > straightforawrd question.
> > > > I'm getting a string (managed string, or system.string, if you
> > > please)..and
> > > > need to convert it to a Byte[] before passing it to a Crypto Service
> > > > Provider. Now, How do I do that?
> > > > Pleae help,
> > > > Regards
> > > > - Mrinal