How to detect if a Text String is Base 64 Encoded in C# .NET Framework

Cloudmersive
1 min readApr 17, 2020

--

Having a good detection solution for base 64 encoding can be an excellent convenience. With that goal in mind, we are going to dive into implementing it using .NET Framework. Prepare to be blown away by the easiness of this method.

Installation comes first:

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 2.2.0

Now we need to call our EditTextBase64Detect function, with these lines of code here.

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class EditTextBase64DetectExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new EditTextApi();var request = new Base64DetectRequest(); // Base64DetectRequest | Input requesttry{// Detect, check if text string is base 64 encodedBase64DetectResponse result = apiInstance.EditTextBase64Detect(request);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditTextApi.EditTextBase64Detect: " + e.Message );}}}}

Just like that, we are done. Simply enter any strings that need to be tested for base 64. Want more lovely APIs like this one? Our document/conversion client also contains format conversion methods as well as file editing capabilities.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet