Answers for "base64 decode"

PHP
1

buffer from base64

const b64string = /* whatever */;
const buf = Buffer.from(b64string, 'base64');
Posted by: Guest on October-28-2020
0

JavaScriptSerializer() and convert to base64

class Program
{
    static void Main(string[] args)
    {
        var account = new ExternalAccount() { Name = "Someone" };
        string json = JsonConvert.SerializeObject(account);
        string base64EncodedExternalAccount = Convert.ToBase64String(Encoding.UTF8.GetBytes(json));
        byte[] byteArray = Convert.FromBase64String(base64EncodedExternalAccount);

        string jsonBack = Encoding.UTF8.GetString(byteArray);
        var accountBack = JsonConvert.DeserializeObject<ExternalAccount>(jsonBack);
        Console.WriteLine(accountBack.Name);
        Console.ReadLine();
    }
}

[Serializable]
public class ExternalAccount
{
    public string Name { get; set; }
}
Posted by: Guest on April-27-2020
2

decode base64

import base64, sys; base64.decode(open(sys.argv[1], "rb"), open(sys.argv[2], "wb"))
Posted by: Guest on August-01-2021

Browse Popular Code Answers by Language