当前位置:网站首页>Randomly generate session_ id
Randomly generate session_ id
2022-07-07 05:46:00 【Month better】
// transformUint8ArrayToBase64
function transformUint8ArrayToBase64(array) {
var binary = "";
for (var len = array.byteLength, i = 0; i < len; i++) {
binary += String.fromCharCode(array[i]);
}
return window.btoa(binary).replace(/=/g, "");
}
function randomSessionId() {
let ua = new Uint8Array(20);
new DataView(ua.buffer).setUint32(0, Math.floor(+new Date() / 1000));
let crypto = window.crypto || window.msCrypto;
if (crypto) {
crypto.getRandomValues(ua.subarray(4, 20));
}
return (
"1." +
transformUint8ArrayToBase64(ua)
.replace(/\+/g, "-")
.replace(/\//g, "_")
);
}
console.log(" Random generation session_id:", randomSessionId());
边栏推荐
- AI face editor makes Lena smile
- Polynomial locus of order 5
- Paper reading [semantic tag enlarged xlnv model for video captioning]
- K6el-100 leakage relay
- 分布式全局ID生成方案
- Introduction to distributed transactions
- make makefile cmake qmake都是什么,有什么区别?
- 高级程序员必知必会,一文详解MySQL主从同步原理,推荐收藏
- Message queue: how to deal with message backlog?
- Go 语言的 Context 详解
猜你喜欢
[论文阅读] A Multi-branch Hybrid Transformer Network for Corneal Endothelial Cell Segmentation
Differences and introduction of cluster, distributed and microservice
消息队列:消息积压如何处理?
ForkJoin最全详解(从原理设计到使用图解)
Digital innovation driven guide
The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
AI人脸编辑让Lena微笑
论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】
判断文件是否为DICOM文件
什么是依赖注入(DI)
随机推荐
集群、分布式、微服务的区别和介绍
bat 批示处理详解
Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
An example of multi module collaboration based on NCF
Mapbox Chinese map address
Leetcode: maximum number of "balloons"
消息队列:如何确保消息不会丢失
async / await
毕业之后才知道的——知网查重原理以及降重举例
What are the common message queues?
[论文阅读] A Multi-branch Hybrid Transformer Network for Corneal Endothelial Cell Segmentation
Common skills and understanding of SQL optimization
Message queue: how to handle repeated messages?
What is message queuing?
Dj-zbs2 leakage relay
5. Data access - entityframework integration
《HarmonyOS实战—入门到开发,浅析原子化服务》
Lombok plug-in
淘寶商品詳情頁API接口、淘寶商品列錶API接口,淘寶商品銷量API接口,淘寶APP詳情API接口,淘寶詳情API接口
SAP webservice 测试出现404 Not found Service cannot be reached