https://github.com/Envoy-VC/noir_base64_lib
https://github.com/Envoy-VC/noir_base64_lib
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/Envoy-VC/noir_base64_lib
- Owner: Envoy-VC
- License: mit
- Created: 2024-10-20T05:01:28.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-10-20T05:08:07.000Z (6 months ago)
- Last Synced: 2025-03-16T12:41:07.539Z (about 1 month ago)
- Language: Noir
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-noir - Noir Base64 Library - extension of `noir_base64` with support for Vectors and Base64 URL encoding and decoding (Libraries / Data Type Manipulation)
README
# 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
- `base46_encode`: Encodes a fixed size array of bytes into a base64 encoded array.
- `base46_encode_var`: Encodes a vector of bytes into a base64 encoded vector.
- `base46_encode_url`: Encodes a fixed size array of bytes into a base64 URL encoded array.
- `base64_encode_url_var`: Encodes a vector of bytes into a base64 URL encoded vector.### Decoding functions
- `base46_decode`: Decodes a base64 encoded array into a fixed size array of bytes.
- `base46_decode_var`: Decodes a base64 encoded vector of bytes into a vector.
- `base64_decode_url`: Decodes a base64 URL encoded array into a fixed size array of bytes.
- `base64_decode_url_var`: Decodes a base64 URL encoded vector of bytes into a vector.## Installation
In your `Nargo.toml` file, add the version of this library you would like to install under dependency:
```toml
[dependencies]
noir_base64_lib = { tag = "v1.0.0", git = "https://github.com/Envoy-VC/noir_base64_lib" }
```## Usage
For Fixed Size Arrays
```noir
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
```noir
fn main() {
let input: Vec = "Hello World!".as_bytes_vec();
let expected: Vec = "SGVsbG8gV29ybGQh".as_bytes_vec();let result: Vec = base64_encode_var(input);
let decoded: Vec = base64_decode_var(result);
}
```