hexBytes
This encodes and decodes hex bytes
Created by: hackvertor
Installed 1 times
Category: Convert
Created on: Thursday, December 19, 2024 at 12:47:47 PM
Updated on: Monday, December 30, 2024 at 8:12:22 AM
Tag arguments
[]
Code
class hexBytes {
encode(input) {
return input.replaceAll(/[\x00-\xff]/gi, function (c) {
return c.codePointAt(0).toString(16).padStart(2, "0");
});
}
decode(input) {
return input.replaceAll(/[a-fA-F0-9]{2}/gi, function (hex) {
return String.fromCodePoint(parseInt(hex, 16));
});
}
}