Is decoding base64 strings safe Is decoding base64 strings safe flask flask

Is decoding base64 strings safe


It is not safe to assume that a user provided file is safe. The base64 encoding does not have any effect on safety.

To validate if the provided file is an image, you can use the imghdr module in the standard library, which "determines the type of image contained in a file or byte stream."

You can pass the image as a byte stream directly to imghdr rather than saving it as a file.