ShortGuid--简单便捷高效不区分大小写的短唯一ID
来源:互联网 发布:java开发专业技能 编辑:程序博客网 时间:2024/06/05 05:25
采用base36编码的GUID是一个简单便捷的好办法
public static class ShortGuid { // I choose the base 36 because it generates little bit longer than 62. // base36 vs. base62 vs. guid // 25-26 vs. 22-23 vs. 36 private static readonly char[] BASE36 = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; private static string ToBase36String(byte[] toConvert, bool bigEndian = false) { if (bigEndian) Array.Reverse(toConvert); // !BitConverter.IsLittleEndian might be an alternative BigInteger dividend = new BigInteger(toConvert); var builder = new StringBuilder(); while (dividend != 0) { BigInteger remainder; dividend = BigInteger.DivRem(dividend, 36, out remainder); builder.Insert(0, BASE36[Math.Abs(((int)remainder))]); } return builder.ToString(); } public static String NewGuid() { return ToBase36String(Guid.NewGuid().ToByteArray()); } }
0 0
- ShortGuid--简单便捷高效不区分大小写的短唯一ID
- mysql唯一索引 不区分大小写
- mysql 唯一性索引 不区分大小写
- 不区分大小写的strstr
- MSSQL默认是不区分大小写的
- C#不区分大小写的比较
- vi 下不区分大小写的搜索
- MySQL查询不区分大小写的原因
- 不区分大小写的strCaseStr---改造strstr
- MySQL查询不区分大小写的问题
- git不区分大小写的处理方法
- SQL Server不区分大小写的问题
- ios 不区分字符串大小写的比较
- java 不区分KEY大小写的MAP
- java 不区分KEY大小写的MAP
- linux下不区分大小写的搜索
- tomcat url不区分大小写的设置
- ilike---不区分大小写的模糊查询
- redis 基本命令学习一(strings、hashes、lists)
- common-codec加解密base64
- Lua时间转化 秒转换为日期
- 无限极分类查找子孙树
- 将Solr5部署到生产环境
- ShortGuid--简单便捷高效不区分大小写的短唯一ID
- 检测wifi是否需要portal验证 公共场所wifi验证
- CSS 属性选择器
- HTML如何使用模板(1)
- ios UIWebView播放视频、音频退出时停止播放
- Ubuntu安装Caffe并训练MNIST
- C# 自定义Json解析工具
- MVVM模式下如何使用ReactiveCocoa响应链式编程<二>
- ld: library not found for -lAFNetworking