当前位置:网站首页>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());
边栏推荐
猜你喜欢

Leakage relay jd1-100

论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】
![Paper reading [semantic tag enlarged xlnv model for video captioning]](/img/e3/633f6aac7a51ad7b3dc0e45dbe1f60.png)
Paper reading [semantic tag enlarged xlnv model for video captioning]

The navigation bar changes colors according to the route

WEB架构设计过程

Web architecture design process

Dj-zbs2 leakage relay

Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface

分布式事务解决方案之2PC

什么是消息队列?
随机推荐
English grammar_ Noun possessive
Hcip seventh operation
Digital innovation driven guide
Mybaits之多表查询(联合查询、嵌套查询)
K6el-100 leakage relay
消息队列:重复消息如何处理?
Win configuration PM2 boot auto start node project
ssm框架的简单案例
集群、分布式、微服务的区别和介绍
Différenciation et introduction des services groupés, distribués et microservices
Flinksql read / write PgSQL
I didn't know it until I graduated -- the principle of HowNet duplication check and examples of weight reduction
SQL query: subtract the previous row from the next row and make corresponding calculations
Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
[论文阅读] Semi-supervised Left Atrium Segmentation with Mutual Consistency Training
AI face editor makes Lena smile
分布式全局ID生成方案
What is dependency injection (DI)
分布式事务解决方案之TCC
An example of multi module collaboration based on NCF