add hexToUtf8, utf8ToHex
This commit is contained in:
parent
1bbbd4f389
commit
104626bf72
2
dist/utils/security.util.cjs.map
vendored
2
dist/utils/security.util.cjs.map
vendored
File diff suppressed because one or more lines are too long
2
dist/utils/security.util.js.map
vendored
2
dist/utils/security.util.js.map
vendored
File diff suppressed because one or more lines are too long
18
dist/utils/string.util.cjs
vendored
18
dist/utils/string.util.cjs
vendored
@ -24,11 +24,13 @@ __export(string_util_exports, {
|
||||
compressUuid: () => compressUuid,
|
||||
hexToBase32: () => hexToBase32,
|
||||
hexToBase58: () => hexToBase58,
|
||||
hexToUtf8: () => hexToUtf8,
|
||||
isObjectId: () => isObjectId,
|
||||
isTrue: () => isTrue,
|
||||
isUUID: () => isUUID,
|
||||
string10to62: () => string10to62,
|
||||
string62to10: () => string62to10
|
||||
string62to10: () => string62to10,
|
||||
utf8ToHex: () => utf8ToHex
|
||||
});
|
||||
module.exports = __toCommonJS(string_util_exports);
|
||||
function isTrue(obj) {
|
||||
@ -125,6 +127,16 @@ function compressHex(e, r) {
|
||||
function isUUID(uuid) {
|
||||
return reNormalUUID.test(uuid);
|
||||
}
|
||||
function hexToUtf8(hexString) {
|
||||
let _hexString = hexString.replace(/^0x/, "");
|
||||
let buffer = Buffer.from(_hexString, "hex");
|
||||
return buffer.toString("utf8");
|
||||
}
|
||||
function utf8ToHex(utf8String) {
|
||||
const buffer = Buffer.from(utf8String, "utf8");
|
||||
const hexString = buffer.toString("hex");
|
||||
return hexString;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
base58ToHex,
|
||||
@ -132,10 +144,12 @@ function isUUID(uuid) {
|
||||
compressUuid,
|
||||
hexToBase32,
|
||||
hexToBase58,
|
||||
hexToUtf8,
|
||||
isObjectId,
|
||||
isTrue,
|
||||
isUUID,
|
||||
string10to62,
|
||||
string62to10
|
||||
string62to10,
|
||||
utf8ToHex
|
||||
});
|
||||
//# sourceMappingURL=string.util.cjs.map
|
2
dist/utils/string.util.cjs.map
vendored
2
dist/utils/string.util.cjs.map
vendored
File diff suppressed because one or more lines are too long
4
dist/utils/string.util.d.cts
vendored
4
dist/utils/string.util.d.cts
vendored
@ -28,5 +28,7 @@ declare const hexToBase32: (hexString: string) => string;
|
||||
declare function compressUuid(e: string, t?: boolean): string;
|
||||
declare function compressHex(e: string, r: number): string;
|
||||
declare function isUUID(uuid: string): boolean;
|
||||
declare function hexToUtf8(hexString: any): string;
|
||||
declare function utf8ToHex(utf8String: any): string;
|
||||
|
||||
export { base58ToHex, compressHex, compressUuid, hexToBase32, hexToBase58, isObjectId, isTrue, isUUID, string10to62, string62to10 };
|
||||
export { base58ToHex, compressHex, compressUuid, hexToBase32, hexToBase58, hexToUtf8, isObjectId, isTrue, isUUID, string10to62, string62to10, utf8ToHex };
|
||||
|
4
dist/utils/string.util.d.ts
vendored
4
dist/utils/string.util.d.ts
vendored
@ -28,5 +28,7 @@ declare const hexToBase32: (hexString: string) => string;
|
||||
declare function compressUuid(e: string, t?: boolean): string;
|
||||
declare function compressHex(e: string, r: number): string;
|
||||
declare function isUUID(uuid: string): boolean;
|
||||
declare function hexToUtf8(hexString: any): string;
|
||||
declare function utf8ToHex(utf8String: any): string;
|
||||
|
||||
export { base58ToHex, compressHex, compressUuid, hexToBase32, hexToBase58, isObjectId, isTrue, isUUID, string10to62, string62to10 };
|
||||
export { base58ToHex, compressHex, compressUuid, hexToBase32, hexToBase58, hexToUtf8, isObjectId, isTrue, isUUID, string10to62, string62to10, utf8ToHex };
|
||||
|
14
dist/utils/string.util.js
vendored
14
dist/utils/string.util.js
vendored
@ -93,16 +93,28 @@ function compressHex(e, r) {
|
||||
function isUUID(uuid) {
|
||||
return reNormalUUID.test(uuid);
|
||||
}
|
||||
function hexToUtf8(hexString) {
|
||||
let _hexString = hexString.replace(/^0x/, "");
|
||||
let buffer = Buffer.from(_hexString, "hex");
|
||||
return buffer.toString("utf8");
|
||||
}
|
||||
function utf8ToHex(utf8String) {
|
||||
const buffer = Buffer.from(utf8String, "utf8");
|
||||
const hexString = buffer.toString("hex");
|
||||
return hexString;
|
||||
}
|
||||
export {
|
||||
base58ToHex,
|
||||
compressHex,
|
||||
compressUuid,
|
||||
hexToBase32,
|
||||
hexToBase58,
|
||||
hexToUtf8,
|
||||
isObjectId,
|
||||
isTrue,
|
||||
isUUID,
|
||||
string10to62,
|
||||
string62to10
|
||||
string62to10,
|
||||
utf8ToHex
|
||||
};
|
||||
//# sourceMappingURL=string.util.js.map
|
2
dist/utils/string.util.js.map
vendored
2
dist/utils/string.util.js.map
vendored
File diff suppressed because one or more lines are too long
@ -146,3 +146,22 @@ export function isUUID(uuid: string) {
|
||||
return reNormalUUID.test(uuid)
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function hexToUtf8(hexString) {
|
||||
// Remove any leading "0x" prefix and split into pairs of characters
|
||||
let _hexString = hexString.replace(/^0x/, '')
|
||||
let buffer = Buffer.from(_hexString, 'hex')
|
||||
return buffer.toString('utf8')
|
||||
}
|
||||
|
||||
export function utf8ToHex(utf8String) {
|
||||
// Create a Buffer object from the UTF-8 string
|
||||
const buffer = Buffer.from(utf8String, 'utf8')
|
||||
|
||||
// Convert the Buffer object to a hex string
|
||||
const hexString = buffer.toString('hex')
|
||||
|
||||
return hexString
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user