One of these
   g = Guid(enc.GetBytes(myString1))
   g = Guid(myString1);
should construct a GUID that matches the one you started with.  

If neither works, you'll have to format the bytes in myString1 to produce the 
{...-...-...-...} format that the Guid(String) constructor might be looking for 
(it's not documented; sigh).

Good luck.

At 01:41 PM 8/23/2006, Hevel, Shawn wrote
>Barry,
>
>Thanks for the reply.  I'm trying now to do the reverse but am a little
>stuck.  I've tried the following but it's not getting back to the Guid I
>originally started out with.  
>
>Encoding enc = Encoding.ASCII;
>string myString1 = enc.GetString(Convert.FromBase64String(encoded));
>
>Is this what you had in mind?
>
>Thanks,
>
>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: Barry Kelly [mailto:[EMAIL PROTECTED] 
>Sent: Wednesday, August 23, 2006 10:34 AM
>To: [email protected]
>Subject: Re: [ADVANCED-DOTNET] Guid question
>
>"Hevel, Shawn" <[EMAIL PROTECTED]> wrote:
>
>> I've got a Guid 36 positions long.  I need a way to encrypt this and
>decript
>> this value.  When I encrypt the value the length can be no longer than 30
>> positions.  Is there a way to encrypt the Guid into a length of 30 and
>> decript is back to a length of 36, without losing the original value of
>the
>> Guid?
>
>If obfuscation is all you need, you can Base64 encode the byte array
>form of the guid, it'll end up around 24 characters or so:
>
>---8<---
>using System;
>
>class App
>{
>    static void Main()
>    {
>        Guid guid = Guid.NewGuid();
>        string encoded = Convert.ToBase64String(
>                guid.ToByteArray());
>        Console.WriteLine(encoded);
>        Console.WriteLine(encoded.Length);
>    }
>}
>--->8---
>
>Do the reverse to get it back.
>
>-- Barry
>
>-- 
>http://barrkel.blogspot.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


J. Merrill / Analytical Software Corp

===================================
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