Skip to content

Commit 966d2cd

Browse files
committed
🐱 Base62: Add ToBase62 extension method for Guid
This shortens a GUID string from 32 chars down to 21/22 without loss of complexity. Closes #62
1 parent cc77ca9 commit 966d2cd

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

System/Base62.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ namespace System
3737
/// </summary>
3838
static partial class Base62
3939
{
40+
/// <summary>
41+
/// Encodes a Guid into a base62 string.
42+
/// </summary>
43+
public static string ToBase62(this Guid guid)
44+
=> Encode(BigInteger.Abs(new BigInteger(guid.ToByteArray())));
45+
4046
/// <summary>
4147
/// Encodes a numeric value into a base62 string.
4248
/// </summary>

0 commit comments

Comments
 (0)