当前位置:网站首页>随机生成session_id
随机生成session_id
2022-07-06 23:45:00 【月来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("随机生成session_id:", randomSessionId());
边栏推荐
- 阿里云的神龙架构是怎么工作的 | 科普图解
- 京东商品详情页API接口、京东商品销量API接口、京东商品列表API接口、京东APP详情API接口、京东详情API接口,京东SKU信息接口
- The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
- Mysql database learning (8) -- MySQL content supplement
- Phenomenon analysis when Autowired annotation is used for list
- Where is NPDP product manager certification sacred?
- Leakage relay llj-100fs
- 漏电继电器LLJ-100FS
- English语法_名词 - 所有格
- JD commodity details page API interface, JD commodity sales API interface, JD commodity list API interface, JD app details API interface, JD details API interface, JD SKU information interface
猜你喜欢

利用OPNET进行网络仿真时网络层协议(以QoS为例)的使用、配置及注意点

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

漏电继电器JELR-250FG

English语法_名词 - 所有格

消息队列:消息积压如何处理?

sql优化常用技巧及理解

C#可空类型

Two person game based on bevy game engine and FPGA

【js组件】自定义select

Preliminary practice of niuke.com (9)
随机推荐
Talk about mvcc multi version concurrency controller?
How digitalization affects workflow automation
论文阅读【Open-book Video Captioning with Retrieve-Copy-Generate Network】
高级程序员必知必会,一文详解MySQL主从同步原理,推荐收藏
Let f (x) = Σ x^n/n^2, prove that f (x) + F (1-x) + lnxln (1-x) = Σ 1/n^2
删除文件时提示‘源文件名长度大于系统支持的长度’无法删除解决办法
Phenomenon analysis when Autowired annotation is used for list
Egr-20uscm ground fault relay
TabLayout修改自定义的Tab标题不生效问题
Common skills and understanding of SQL optimization
ssm框架的简单案例
Mysql database learning (7) -- a brief introduction to pymysql
拼多多商品详情接口、拼多多商品基本信息、拼多多商品属性接口
数字化如何影响工作流程自动化
Flink SQL realizes reading and writing redis and dynamically generates hset key
Preliminary practice of niuke.com (9)
Photo selector collectionview
Life experience of an update statement
架构设计的五个核心要素
[JS component] date display.