Decode the passed base64 encoded input string into the unencoded original input in either binary or string formats.
Parameter | Type | Description |
---|---|---|
input | string | The string to base64 decode. |
encoding (optional) | string | The base64 encoding to use. Available options are: - "std": the standard encoding with = padding chars and + and / characters in encoding alphabet. This is the default. - "rawstd": like std but without = padding characters. - "url": URL safe version of std, encoding alphabet doesn't contain + and / characters, but rather - and _ characters. - "rawurl": like url but without = padding characters. |
format (optional) | string | If "s" return the data as a string, otherwise if unspecified an ArrayBuffer object is returned. |
Returns
Type | Description |
---|---|
ArrayBuffer / string | The base64 decoded version of the input string in either string or ArrayBuffer format, depending on the format parameter. |
Breaking change in v0.32.0
Since k6 v0.32.0 b64decode() returns an ArrayBuffer object by default instead of a string. To return a string pass "s" as the 3rd parameter, e.g. encoding.b64decode(encodedString, 'std', 's').