Home

Awesome

Noir Base64 Library

This library provides implementations for Base64 and URL based encoding and decoding over fixed sized arrays and Vectors in Noir programming language.

Available functions:

Encoding functions

Decoding functions

Installation

In your Nargo.toml file, add the version of this library you would like to install under dependency:

[dependencies]
noir_base64_lib = { tag = "v1.0.0", git = "https://github.com/Envoy-VC/noir_base64_lib" }

Usage

For Fixed Size Arrays

fn main() {
    let input: [u8; 12] = "Hello World!".as_bytes();
    let expected: [u8; 16] = "SGVsbG8gV29ybGQh".as_bytes();

    let result = base64_encode(input);
    assert(result == expected);

    let decoded = base64_decode(result);
    assert(input == decoded);
}

For Vectors

fn main() {
    let input: Vec<u8> = "Hello World!".as_bytes_vec();
    let expected: Vec<u8> = "SGVsbG8gV29ybGQh".as_bytes_vec();

    let result: Vec<u8> = base64_encode_var(input);


    let decoded: Vec<u8> = base64_decode_var(result);
}