惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Register - Security
The Register - Security
Cisco Talos Blog
Cisco Talos Blog
P
Proofpoint News Feed
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Y
Y Combinator Blog
V
Visual Studio Blog
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
博客园 - 叶小钗
V
Vulnerabilities – Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
IT之家
IT之家
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
罗磊的独立博客
C
CXSECURITY Database RSS Feed - CXSecurity.com
V2EX - 技术
V2EX - 技术
T
The Blog of Author Tim Ferriss
小众软件
小众软件
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
DataBreaches.Net
L
LINUX DO - 热门话题
大猫的无限游戏
大猫的无限游戏
V
V2EX
Latest news
Latest news
NISL@THU
NISL@THU
Last Week in AI
Last Week in AI
Spread Privacy
Spread Privacy
云风的 BLOG
云风的 BLOG
S
Secure Thoughts
W
WeLiveSecurity
S
Security @ Cisco Blogs
C
CERT Recently Published Vulnerability Notes
AWS News Blog
AWS News Blog
I
InfoQ
A
About on SuperTechFans
K
Kaspersky official blog
Security Latest
Security Latest
P
Proofpoint News Feed

6Jyc5p+a

【笔记】通过NapCat和AstrBot实现QQ机器人 【笔记】部署NapCat 【笔记】部署AstrBot 【笔记】Poetry学习笔记 【笔记】uv学习笔记 【笔记】Nodejs通过mysql2操作MySQL数据库 【笔记】CodeBuddy学习笔记 【笔记】MiMoCode学习笔记 【笔记】OpenCode使用XiaomMiMo作为供应商 【笔记】OpenCode学习笔记 【笔记】IDEA的AiAssistant使用自定义的Agent 【笔记】MacOS上删除TimeMachine时间机器备份 【笔记】MacOS上部署XiaomiMiloco 【笔记】Docker的上下文 【源码】Python3创建1x1像素的图片 【靶场】xss-labs通关攻略 【靶场】upload-labs通关攻略 【笔记】Brave迁移ProxySwitchyOmega数据到ZeroOmega 【笔记】通过Docker部署DVWA 【笔记】通过Docker部署xss-labs 【笔记】通过Docker部署upload-labs 【笔记】通过Docker部署Vulhub 【笔记】宝塔通过Docker部署SQLI-LABS 【笔记】宝塔部署Docker 【笔记】通过Docker部署SQLI-LABS 【靶场】SQLI-LABS通关攻略 【笔记】MSYS2学习笔记 【笔记】Cygwin学习笔记 【笔记】Windows添加自定义右键菜单项 【笔记】Linux上和MacOS上配置环境变量 【笔记】命令行配置HTTP代理 【笔记】Windows上配置环境变量 【踩坑】Windows上在IDEA中配置Codex报错 【笔记】start学习笔记 【笔记】Windows的CMD命令学习笔记 【笔记】Java的PriorityQueue和PriorityBlockingQueue 【笔记】IDEA通过AIAssistant安装Codex 【笔记】bcrypt学习笔记 【速查表】浏览器默认禁用的不安全端口 【笔记】Astro学习笔记 【代码】Python3实现从NTP服务器同步时间 【笔记】Koa学习笔记 【笔记】Solidity计算字符串的MD5值 【笔记】Hardhat学习笔记 【笔记】Go安装笔记 【笔记】CVE-2024-3094漏洞利用 【笔记】CVE-2026-43284和CVE-2026-43500漏洞利用 【笔记】CVE-2023-3567漏洞利用 【代码】Python3读写M1卡 【笔记】M1卡学习笔记 【笔记】Python3中文转拼音 【代码】Python3生成中国大陆姓名拼音 【代码】Python3爬取中国大陆手机号段 【笔记】Nodejs发送请求 【笔记】Trello通过API添加待办事项 【笔记】Nodejs的流和缓冲区 【笔记】Nodejs的事件 【笔记】Nodejs的文件和目录操作 【笔记】CNVD-2020-10487漏洞利用 【笔记】CVE-2017-12617漏洞利用 【笔记】PHP输出源码 【笔记】PHP的Phar 【笔记】通过Docker部署OnlineTools 【笔记】XML学习笔记 【笔记】Windows的用户和组 【笔记】CVE-2006-7243漏洞利用 【笔记】PHP抑制所有报错 【笔记】HFish学习笔记 【笔记】JumpServer学习笔记 【笔记】Conpot学习笔记 【笔记】南墙WAF学习笔记 【笔记】堡塔云WAF学习笔记 【笔记】Windows的远程桌面服务 【笔记】Windows的防火墙
【代码】JS将目录编号转换为十六进制
6Jyc5p+a · 2026-05-19 · via 6Jyc5p+a

前言

JS将目录编号转换为十六进制

源代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
class HexToc {

constructor(bitValueArrayLength, singleBitLength, config) {

const defaultConfig = {





reverse: false,




noPrefix: false,




separator: ""
}





this.bitValueArray = [0];





this.singleBitLength = 2;




this.config = {
...defaultConfig,
...config
};

if (typeof bitValueArrayLength === "number" && bitValueArrayLength > 0) {
this.#resizeBitValueArray(bitValueArrayLength);
}

if (typeof singleBitLength === "number" && singleBitLength > 0) {
this.singleBitLength = singleBitLength;
}
}







#resizeBitValueArray(length) {
const increment = length - this.bitValueArray.length;
if (increment < 0) {
console.error("不能缩减 bitValueArray 长度");
return;
}
for (let i = 0; i < increment; i++) {
this.bitValueArray.push(0);
}
}







#convertDecToHex(dec) {
if (typeof dec !== "number") {
console.error("参数 dec 必须为数值类型");
return;
}
return dec.toString(16).padStart(this.singleBitLength, "0").slice(-this.singleBitLength).toUpperCase();
}




toString() {
let res = "";
for (const dec of this.bitValueArray) {
res = this.config.reverse ? `${res}${this.config.separator}${this.#convertDecToHex(dec)}` : `${this.#convertDecToHex(dec)}${this.config.separator}${res}`;
}
return this.config.noPrefix ? res : `0x${res}`;
}




getRawData() {
return this.bitValueArray;
}







setBitValueByArrayIndex(arrayIndex, dec) {
if (arrayIndex < 0) {
console.error("arrayIndex 不能小于 0");
return;
}
if (arrayIndex > this.bitValueArray.length) {
console.error("arrayIndex 不能大于 bitValueArray 长度");
return;
}
this.bitValueArray[arrayIndex] = dec;
return this;
}







setBitValueByTocDepth(tocDepth, dec) {
if (tocDepth - 1 < 0) {
console.error("tocDepth - 1 不能小于 0\n或许你应该使用 setBitValueByArrayIndex() ?");
return;
}
if (tocDepth - 1 > this.bitValueArray.length) {
console.error("tocDepth - 1 不能大于 bitValueArray 长度");
return;
}
this.bitValueArray[tocDepth - 1] = dec;
return this;
}





setBitValueArray(decArray) {
for (let i = 0; i < decArray.length; i++) {
this.bitValueArray[i] = decArray[i];
}
return this;
}
}

完成