Convert a base64 string to a Uint8Array.
The input string must be a valid base64 string, otherwise an error will be thrown.
The encoding parameter is optional and defaults to 'utf-8'.
import { fromBase64 } from '@aws-lambda-powertools/commons/utils/base64';const encodedValue = 'aGVsbG8gd29ybGQ=';const decoded = fromBase64(encodedValue);// new Uint8Array([ 97, 71, 86, 115, 98, 71, 56, 103, 100, 50, 57, 121, 98, 71, 81, 61 ]); Copy
import { fromBase64 } from '@aws-lambda-powertools/commons/utils/base64';const encodedValue = 'aGVsbG8gd29ybGQ=';const decoded = fromBase64(encodedValue);// new Uint8Array([ 97, 71, 86, 115, 98, 71, 56, 103, 100, 50, 57, 121, 98, 71, 81, 61 ]);
The base64 string to convert to a Uint8Array
Optional
The encoding of the input string (optional)
Convert a base64 string to a Uint8Array.
The input string must be a valid base64 string, otherwise an error will be thrown.
The encoding parameter is optional and defaults to 'utf-8'.
Example