Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function formatBytes32String(text) {
// Get the bytes
var bytes = utf8_1.toUtf8Bytes(text);
// Check we have room for null-termination
if (bytes.length > 31) {
throw new Error("bytes32 string must be less than 32 bytes");
}
// Zero-pad (implicitly null-terminates)
return bytes_1.hexlify(bytes_1.concat([bytes, constants_1.HashZero]).slice(0, 32));
}
exports.formatBytes32String = formatBytes32String;