Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Create URL Safe and Cryptographically Strong Short GUID
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Text; using System.Security.Cryptography; namespace Rextester { public class Program { public static void Main(string[] args) { byte[] bytes = new byte[16]; using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create()) { provider.GetBytes(bytes); } var guid = new Guid(bytes); Console.WriteLine(guid); var shortGuid = guid.ToShortString(); Console.WriteLine(shortGuid); } } public static class GuidHelper { public static string ToShortString(this Guid guid) { return Convert.ToBase64String(guid.ToByteArray()) .Substring(0, 22) .Replace("/", "_") .Replace("+", "-"); } } }
run
|
edit
|
history
|
help
0
asxsadxsdf
C# Calculator Simple
Main 5.5
Hello World!
mine
test
Unity Character Controller Version 1
hello
1
https://www.facebook.com/gluncev