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

推荐订阅源

GbyAI
GbyAI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
IT之家
IT之家
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
N
News | PayPal Newsroom
Cloudbric
Cloudbric
Webroot Blog
Webroot Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Simon Willison's Weblog
Simon Willison's Weblog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
Attack and Defense Labs
Attack and Defense Labs
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
S
Secure Thoughts
T
Tor Project blog
Latest news
Latest news
aimingoo的专栏
aimingoo的专栏
V2EX - 技术
V2EX - 技术
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Securelist
T
Tenable Blog
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
博客园 - Franky
T
Troy Hunt's Blog
量子位
大猫的无限游戏
大猫的无限游戏
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
MongoDB | Blog
MongoDB | Blog
H
Heimdal Security Blog
D
Docker
W
WeLiveSecurity
Stack Overflow Blog
Stack Overflow Blog
G
Google Developers Blog
博客园 - 叶小钗
腾讯CDC
The Hacker News
The Hacker News
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
Project Zero
Project Zero
Martin Fowler
Martin Fowler

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;
}
}

完成