Hi!!!
I’m using crypto extension to generate external_ids
in the body.
This extension generates in [object ArrayBuffer]
, how to convert this type to String?
@PriKitice Hi, could u give some details? Why do want to convert an array to String? And could u share your sample code here? Maybe we can help u
Hi!
I want to generate a hex code (crypto) in the external_id attribute, see the payload:
function factoryJson() {
return [
{
"external_id": “code crypto here!!!”
"guardian": {
….
}
}
]
Hi @PriKitice,
Hex codes are really just a hexadecimal encoding (string of characters in the range [0-9a-f]) of some underlying bytes (represented as an ArrayBuffer). Many of the crypto functions from k6 let you specify the outputEncoding
. For instance, using the hmac
, or sha256
functions, you can set outputEnconding
to ‘hex’ to get its value encoded in hexadecimal.
Thus, I assume that you’re trying to use a function that does not expose this parameter. Would you be able to share an anonymized example of the function call you’re making in place of the “code crypto here!!!” from your example? Or at the very least, indicate to use which crypto function you’re using in its place