The reason why i ask this is that final() from crypto can only output hexadecimal, binary or ascii data. It is designed to carry data stored in binary format across the network. This process will increase the size by 33%.
AI is for EVERYONE with Microsoft Vice Chair & President Brad Smith
The common method to store images in a database is to convert the image to base64 data before storing the data.
You can use btoa() and atob() to convert to and from base64 encoding.
Base64 is a binary to a text encoding scheme that represents binary data in an ascii string format. Remember base64 is primarily intended for representing binary data in ascii, for storing in a char field in a database or sending via. Title and first sentence ask different question. There appears to be some confusion in the comments regarding what these functions accept/return, so… btoa().
Ask yourself do you really need to do this? You can determine if a given string is valid base64 encoded string, but you cannot determine if a string is base64 encoded or not.