Skip to content

Commit

Permalink
Adds base64 decoding support
Browse files Browse the repository at this point in the history
  • Loading branch information
AffectedArc07 committed Oct 24, 2023
1 parent 85631fa commit f2c1be0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rust-g"
edition = "2021"
version = "3.0.0"
version = "3.1.0"
authors = [
"Bjorn Neergaard <[email protected]>",
"Tad Hardesty <[email protected]>",
Expand Down
3 changes: 3 additions & 0 deletions dmsrc/hash.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});
Expand Down

0 comments on commit f2c1be0

Please sign in to comment.