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
Int number to String Array
Padma narwade
Order of Ops Decimals 5.1 (changed result.ToString(fmt2))
Student Cables
from Base or Derived
Rijndael
ProWIN2
Bitcoins expectative :'v
static, private, public constructor in C#
A2Z Dice Roll