Hi, does anyone know the easiest way to encode hex string (generated by k6 UUIDV4()) to ‘base32’?
I hope it clarify.
Thanks for your reply.
Ya, as you said, I couldn’t find any builtin function within k6 but since importing external modules within k6 script is also not that straight forward, it makes it bit difficult.
Since I can’t directly import a base32 npm package (like base32) , looks like I would need to import the whole base32 code within my project and then use it to perform encoding.
Is that the only possible way right now with k6?
You can import directly the script from github as in
import base32 from "https://raw.githubusercontent.com/agnoster/base32-js/master/dist/base32.js"; var encoded = base32.encode('some data to encode') var decoded = base32.decode(encoded) console.log(encoded, decoded)
Thanks for a quicker solution.
Do you know if using this script we can control the output to be od 26 bytes rather than 52 bytes.
I am not getting your question.
If you do base32 encoding it is encoding in a particular way I am not certain you can control how big the output is, but maybe there are some variants I am not familiar.