diff --git a/Cargo.lock b/Cargo.lock index 3b8c421a..3b0ab2d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2206,7 +2206,7 @@ dependencies = [ [[package]] name = "rust-g" -version = "3.0.0" +version = "3.1.0" dependencies = [ "aho-corasick", "base64", diff --git a/Cargo.toml b/Cargo.toml index bdd040f0..6302a506 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rust-g" edition = "2021" -version = "3.0.0" +version = "3.1.0" authors = [ "Bjorn Neergaard ", "Tad Hardesty ", diff --git a/dmsrc/hash.dm b/dmsrc/hash.dm index c666d2e2..653255db 100644 --- a/dmsrc/hash.dm +++ b/dmsrc/hash.dm @@ -10,6 +10,9 @@ #define RUSTG_HASH_XXH64 "xxh64" #define RUSTG_HASH_BASE64 "base64" +#define rustg_encode_base64(str) rustg_hash_string(RUSTG_HASH_BASE64, str) +#define rustg_decode_base64(str) RUSTG_CALL(RUST_G, "decode_base64")(str) + #ifdef RUSTG_OVERRIDE_BUILTINS #define md5(thing) (isfile(thing) ? rustg_hash_file(RUSTG_HASH_MD5, "[thing]") : rustg_hash_string(RUSTG_HASH_MD5, thing)) #endif diff --git a/src/hash.rs b/src/hash.rs index 93ae7989..ee959fe0 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -18,6 +18,10 @@ byond_fn!(fn hash_string(algorithm, string) { string_hash(algorithm, string).ok() }); +byond_fn!(fn decode_base64(string) { + Some(base64::prelude::BASE64_STANDARD.decode(string).unwrap()) +}); + byond_fn!(fn hash_file(algorithm, string) { file_hash(algorithm, string).ok() });