Sweet.  Excellent.  That is exactly what I needed.  Thank you all for the
help.


Shawn Hevel, API, AIT
Lead Programmer Analyst
Information Technology Department
South Carolina Farm Bureau Insurance Companies
Phone: (803) 936-4331
Fax: (803) 936-4629
Work Email: [EMAIL PROTECTED]
Home Email: [EMAIL PROTECTED]


-----Original Message-----
From: Rocco Martin [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 23, 2006 6:15 PM
To: [email protected]
Subject: Re: [ADVANCED-DOTNET] Guid question

It looks like you are injecting an unnecessary step.  Don't worry about
encoding the resulting byte array back into a string; the constructor for
Guid will be perfectly happy with the byte array.

<Sending>
Guid guid = Guid.NewGuid();
string encoded = Convert.ToBase64String(guid.ToByteArray());

<Receiving>
Guid reconstitutedGuid = new Guid(Convert.FromBase64String(encoded));

However, please go back to your original statement and reevaluate.  If you
want this data to be secure, Base64 will not protect you from anyone who
knows much about data streams.  You may wish to truly encrypt the Guid
before transmitting.

Cheers,
- Rocco


On 8/23/06, Shawn Hevel <[EMAIL PROTECTED]> wrote:
>
> >>   g = Guid(enc.GetBytes(myString1))
> >>   g = Guid(myString1);
>
> I figured it out.  The new keyword is needed.
>
> g = new Guid(enc.GetBytes(myString1))
> g = new Guid(myString1);
>
> I tried this both ways but the guids are not the same.  Here is my code:
>
> Encoding enc = Encoding.ASCII;
> Guid guid = Guid.NewGuid();
> string encoded = Convert.ToBase64String(guid.ToByteArray());
> string myString1 = enc.GetString(Convert.FromBase64String(encoded));
> Guid g = new Guid(enc.GetBytes(myString1));
>
> //This statement gives an error.
> //Guid g = new Guid(myString1);
>
> Any ideas on how to correct this?
>
> Thanks,
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to