Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to check if a string is correctly encoded as base64 in javascript

function isBase64(str) {
    if (str ==='' || str.trim() ===''){ return false; }
    try {
        return btoa(atob(str)) == str;
    } catch (err) {
        return false;
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #string #correctly #encoded #javascript
ADD COMMENT
Topic
Name
1+1 =