Files
bd-short-message-platform/app/middleware/utils/packageItem.js

8 lines
305 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 判断十六进制数据的长度,若长度不满足条件,则在左侧补0,直至长度满足条件
module.exports = (length, data) => {
let item = data.toString(16);
for (let i = 0; i < (length * 2) - data.toString(16).length; i++) {
item = '0' + item;
}
return item;
};