zoukankan
html css js c++ java
vb的GUID生成算法
源代码推荐:vb的GUID生成算法
'
RETURNS: GUID if successful; blank string otherwise.
'
Unlike the GUIDS in the registry, this function returns GUID
'
without "-" characters. See comments for how to modify if you
'
want the dash.
Public
Function
GUID()
As
String
Dim
lRetVal
As
Long
Dim
udtGuid
As
GUID
Dim
sPartOne
As
String
Dim
sPartTwo
As
String
Dim
sPartThree
As
String
Dim
sPartFour
As
String
Dim
iDataLen
As
Integer
Dim
iStrLen
As
Integer
Dim
iCtr
As
Integer
Dim
sAns
As
String
On
Error
GoTo
errorhandler
sAns
=
""
lRetVal
=
CoCreateGuid(udtGuid)
If
lRetVal
=
0
Then
'
First 8 chars
sPartOne
=
Hex
$(udtGuid.PartOne)
iStrLen
=
Len
(sPartOne)
iDataLen
=
Len
(udtGuid.PartOne)
sPartOne
=
String
((iDataLen
*
2
)
-
iStrLen,
"
0
"
) _
&
Trim
$(sPartOne)
'
Next 4 Chars
sPartTwo
=
Hex
$(udtGuid.PartTwo)
iStrLen
=
Len
(sPartTwo)
iDataLen
=
Len
(udtGuid.PartTwo)
sPartTwo
=
String
((iDataLen
*
2
)
-
iStrLen,
"
0
"
) _
&
Trim
$(sPartTwo)
'
Next 4 Chars
sPartThree
=
Hex
$(udtGuid.PartThree)
iStrLen
=
Len
(sPartThree)
iDataLen
=
Len
(udtGuid.PartThree)
sPartThree
=
String
((iDataLen
*
2
)
-
iStrLen,
"
0
"
) _
&
Trim
$(sPartThree)
'
Next 2 bytes (4 hex digits)
'
Final 16 chars
For
iCtr
=
0
To
7
sPartFour
=
sPartFour
&
_
Format$(
Hex
$(udtGuid.PartFour(iCtr)),
"
00
"
)
Next
'
To create GUID with "-", change line below to:
'
sAns = sPartOne & "-" & sPartTwo & "-" & sPartThree _
'
& "-" & sPartFour
sAns
=
sPartOne
&
sPartTwo
&
sPartThree
&
sPartFour
End
If
GUID
=
sAns
Exit
Function
errorhandler:
'
return a blank string if there's an error
Exit
Function
End Function
查看全文
相关阅读:
HttpWebRequest 改为 HttpClient 踩坑记-请求头设置
[k8s]docker calico网络&docker cluster-store
[k8s]jenkins部署在k8s集群
[k8s]zookeeper集群在k8s的搭建(statefulset模式)-pod的调度
[svc]cisco ipsec使用证书认证
[svc]数字证书基础知识
[svc]logstash和filebeat之间ssl加密
[svc]cfssl模拟https站点-探究浏览器如何校验证书
[svc] cisco router as ca server
[svc]对称加密/非对称加密细枝末节-如何做到数据传输的authentication/data integrity/confidentiality(私密)
原文地址:https://www.cnblogs.com/todd/p/104550.html
最新文章
前端这条路,我们该何去何从。
那些年我们一起过的JS闭包,作用域,this,让我们一起划上完美的句号。
面向对象tab栏例子分析
咱们来聊聊JS中的异步,以及如何异步,菜鸟版
JS面向对象逆向学习法,让难理解的统统一边去(1)~
javscript对cookie的操作,以及封装
Nodejs从有门道无门菜鸟起飞教程。
对HTML5新增JS Api的思考
借助数组进行数据的排序
Git使用命令
热门文章
JS滚轮事件封装
asp.net core根据用户权限控制页面元素的显示
如何为 .NET Core CLI 启用 TAB 自动补全功能
Http 压测工具 wrk 基本使用
使用docker部署skywalking
Skywalking部署常见问题以及注意事项
使用 WeihanLi.Npoi 操作 CSV
给IConfiguration写一个GetAppSetting扩展方法
.net core 验证 Options 参数
EFCore使用JSON_VALUE查询json对象的值
Copyright © 2011-2022 走看看