devxlogo

Determine Whether a String is a base64encoded

This function returns TRUE if the string is a base64encoded. Otherwise, it returns FALSE.

'AUTHOR: KEYUR KALARIA'DATE: JULY 24, 2004'VERY USEFUL FUNCTION AND COULD BE HANDY IF YOUR WORKING AROUND ENCRYPTING OR DECRYPTING DATA'PASS THE STRING WHICH YOU WANT TO VERIFY, THE FUNCTION WILL RETURN TRUE IF THE STRING IS A BASE64ENCODED OR WILL RETURN FALSE.Public Shared Function IsBase64String(ByVal s As String) As Boolean	Dim baTemp() As Byte        Try            baTemp = Convert.FromBase64String(s)        Catch ex As FormatException            Return False        Catch ex As ArgumentNullException            Return False        End Try        Return Convert.ToBase64String(baTemp).Equals(s)End Function

Note: This will happily return true for anything that *could* be a base-64 encoded string, but may simply be nonsense characters.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.