The core
library is a curated collection of libraries designed to enhance and
extend the functionality of the Motoko programming language. This repository
aims to provide robust and efficient tools that are essential for building
various applications in Motoko.
The CBOR library provides functions to encode and decode data in CBOR format, which is a compact data format designed for efficient data exchange.
import CBOR "mo:core/cbor/CBOR";
let value = encode(#TextString("Hello world!"));
// "\6C\48\65\6C\6C\6F\20\77\6F\72\6C\64\21"
Canister smart contracts can declare variables as certified. Whenever set, these variables will automatically get a Merkle tree certificate, signed by the Internet Computer blockchain. This allows anyone to verify the authenticity of this type of data using the Internet Computer's public key.
The Crypto library offers a collection of cryptographic functions and utilities, enabling secure data handling and operations within Motoko applications.
The SHA256 submodule provides a robust SHA-256 hashing function, crucial for creating secure digital fingerprints of data.
import SHA256 "mo:core/crypto/SHA256";
let hash = SHA256.sum(Blob.toArray(Text.encodeUtf8("Hello, world!")));
The Encoding library includes various encoding schemes necessary for data manipulation and storage within Motoko applications.
The Binary submodule allows for straightforward encoding and decoding of binary data, facilitating binary data handling in a variety of applications.
The Hex submodule provides functionalities to encode data into hexadecimal format and decode it back, which is useful for debugging and logging.