/// <summary> /// 解码器 /// </summary> /// <param name="input"></param> /// <returns></returns> public static Guid DecodeToGuid(String input) { input = input.TrimEnd('0'); var bytes = UUIDBase58.Decode(input); return(new Guid(Bytes2Hex(bytes))); }
/// <summary> /// 解码器 /// </summary> /// <param name="input"></param> /// <returns></returns> public static string Decode(String input) { input = input.TrimEnd('0'); var bytes = UUIDBase58.Decode(input); return(Bytes2Hex(bytes)); }
/// <summary> /// 编码 /// </summary> /// <param name="guid"></param> /// <returns>返回22位长度字符串</returns> public static String Encode(string guid) { var bytes = Hex2Bytes(guid); var r = UUIDBase58.Encode(bytes); if (r.Length < 22) { r = r.PadRight(22, '0'); } return(r); }
/// <summary> /// 编码 /// </summary> /// <returns>返回22位长度字符串</returns> public static String NewID() { var guid = Guid.NewGuid().ToString(); var bytes = Hex2Bytes(guid); var r = UUIDBase58.Encode(bytes); if (r.Length < 22) { r = r.PadRight(22, '0'); } return(r); }