Constant functions for converting hex- and base64-encoded strings into bytes in Rust. Works on stable Rust and in no-std environments.
Add this to your Crate.toml
:
toml
[dependencies]
const-decoder = "0.1.0"
Example of usage:
rust
use const_decoder::Decoder;
// An Ed25519 secret key.
const SECRET_KEY: [u8; 64] = Decoder::Hex.decode(
b"9e55d1e1aa1f455b8baad9fdf975503655f8b359d542fa7e4ce84106d625b352\
06fac1f22240cffd637ead6647188429fafda9c9cb7eae43386ac17f61115075",
);
See more examples in the crate docs.
[hex-literal
] and [binary_macros
] crates expose similar functionality
as procedural macros. Because of this, macros cannot be used in no-std environments,
while this approach can.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in const-decoder
by you, as defined in the Apache-2.0 license,
shall be dual licensed as above, without any additional terms or conditions.