You can try this one:
public struct ShortGuid
{
private Guid _underlyingGuid;
public ShortGuid(Guid underlyingGuid) : this()
{
_underlyingGuid = underlyingGuid;
}
public static ShortGuid Empty
{
get { return ConvertGuidToShortGuid(Guid.Empty); }
}
public static ShortGuid NewShortGuid()
{
return ConvertGuidToShortGuid(Guid.NewGuid());
}
private static ShortGuid ConvertGuidToShortGuid(Guid guid)
{
return new ShortGuid(guid);
}
public override string ToString()
{
return Convert.ToBase64String(_underlyingGuid.ToByteArray()).EscapeNonCharAndNonDigitSymbols();
}
public bool Equals(ShortGuid other)
{
return other._underlyingGuid.Equals(_underlyingGuid);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (obj.GetType() != typeof (ShortGuid)) return false;
return Equals((ShortGuid) obj);
}
public override int GetHashCode()
{
return _underlyingGuid.GetHashCode();
}
}
where EscapeNonCharAndNonDigitSymbols is an extension method:
public static string EscapeNonCharAndNonDigitSymbols(this string str)
{
if (str == null)
throw new NullReferenceException();
var chars = new List<char>(str.ToCharArray());
for (int i = str.Length-1; i>=0; i--)
{
if (!Char.IsLetterOrDigit(chars[i]))
chars.RemoveAt(i);
}
return new String(chars.ToArray());
}