当前位置:网站首页>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());
边栏推荐
- Reptile exercises (III)
- 爬虫练习题(三)
- Polynomial locus of order 5
- 论文阅读【Semantic Tag Augmented XlanV Model for Video Captioning】
- 集群、分布式、微服務的區別和介紹
- Zero sequence aperture of leakage relay jolx-gs62 Φ one hundred
- Flink SQL realizes reading and writing redis and dynamically generates hset key
- Taobao store release API interface (New), Taobao oauth2.0 store commodity API interface, Taobao commodity release API interface, Taobao commodity launch API interface, a complete set of launch store i
- In memory, I moved from CSDN to blog park!
- TCC of distributed transaction solutions
猜你喜欢
Dynamic memory management
《2022中国低/无代码市场研究及选型评估报告》发布
Determine whether the file is a DICOM file
Pytorch builds neural network to predict temperature
京东商品详情页API接口、京东商品销量API接口、京东商品列表API接口、京东APP详情API接口、京东详情API接口,京东SKU信息接口
Design, configuration and points for attention of network unicast (one server, multiple clients) simulation using OPNET
Paper reading [open book video captioning with retrieve copy generate network]
分布式事务解决方案之2PC
Five core elements of architecture design
[paper reading] semi supervised left atrium segmentation with mutual consistency training
随机推荐
Zero sequence aperture of leakage relay jolx-gs62 Φ one hundred
nodejs获取客户端ip
Preliminary practice of niuke.com (9)
WEB架构设计过程
Polynomial locus of order 5
Simple case of SSM framework
Introduction to distributed transactions
Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
Flinksql 读写pgsql
Get the way to optimize the one-stop worktable of customer service
Dj-zbs2 leakage relay
《HarmonyOS实战—入门到开发,浅析原子化服务》
Modes of optical fiber - single mode and multimode
集群、分布式、微服務的區別和介紹
SQL query: subtract the previous row from the next row and make corresponding calculations
毕业之后才知道的——知网查重原理以及降重举例
ForkJoin最全详解(从原理设计到使用图解)
Reptile exercises (III)
R语言【逻辑控制】【数学运算】
Hcip eighth operation