当前位置:网站首页>随机生成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());
边栏推荐
- 利用OPNET进行网络仿真时网络层协议(以QoS为例)的使用、配置及注意点
- AIDL 与Service
- Getting started with DES encryption
- Design, configuration and points for attention of network specified source multicast (SSM) simulation using OPNET
- 5. Data access - entityframework integration
- Digital innovation driven guide
- 5. 数据访问 - EntityFramework集成
- 不同网段之间实现GDB远程调试功能
- app clear data源码追踪
- High voltage leakage relay bld-20
猜你喜欢
随机推荐
高压漏电继电器BLD-20
基于 hugging face 预训练模型的实体识别智能标注方案:生成doccano要求json格式
[Oracle] simple date and time formatting and sorting problem
消息队列:如何确保消息不会丢失
Educational Codeforces Round 22 B. The Golden Age
App clear data source code tracking
【js组件】date日期显示。
论文阅读【Sensor-Augmented Egocentric-Video Captioning with Dynamic Modal Attention】
Taobao commodity details page API interface, Taobao commodity list API interface, Taobao commodity sales API interface, Taobao app details API interface, Taobao details API interface
[binary tree] binary tree path finding
消息队列:重复消息如何处理?
Design, configuration and points for attention of network specified source multicast (SSM) simulation using OPNET
拼多多商品详情接口、拼多多商品基本信息、拼多多商品属性接口
JVM(二十) -- 性能监控与调优(一) -- 概述
基于NCF的多模块协同实例
English语法_名词 - 所有格
Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
利用OPNET进行网络任意源组播(ASM)仿真的设计、配置及注意点
实现网页内容可编辑
5阶多项式轨迹