"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