Home > Enterprise >  Is '' base64 encoded?
Is '' base64 encoded?

Time:10-19

Is '' base64 encoded?

This question has this answer which suggests no:

if (str ==='' || str.trim() ===''){ return false; }

But some of the other approaches that use regular expressions return true ... For example:

https://stackblitz.com/edit/js-xjubhf

Thoughts?

CodePudding user response:

Yes.

An empty string is encoded (and so decoded) as an empty string in BASE64.

Note: The exact first reference test in the BASE64 standard is the empty string:

BASE64("") = ""

from RFC 4648.

  • Related