Skip to content

Commit

Permalink
replace alphabet: use ~ and . instead of ! and $
Browse files Browse the repository at this point in the history
! and $ are bash-unsafe, and though ~ and . are ugly within the chunked alphadecimals, ugliness is still better than having problems with cli
  • Loading branch information
dr-orlovsky committed Nov 3, 2024
1 parent 983854a commit 5c1ca1a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 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.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "baid64"
version = "0.2.2"
description = "Easy-to-check Base64 encoding for identities"
version = "0.3.0"
description = "Easy-to-check URL-safe Base64 encoding for identities"
keywords = ["base64", "encoding", "mnemonic"]
categories = ["encoding", "value-formatting", "command-line-utilities"]
readme = "README.md"
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub const ID_MIN_LEN: usize = 4;
pub const HRI_MAX_LEN: usize = 16;

pub const BAID64_ALPHABET: &str =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!$";
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~.";

fn check<const LEN: usize>(hri: &'static str, payload: [u8; LEN]) -> [u8; 4] {
let key = sha2::Sha256::digest(hri.as_bytes());
Expand Down Expand Up @@ -104,8 +104,8 @@ where
let orig = s;

use base64::alphabet::Alphabet;
use base64::engine::general_purpose::NO_PAD;
use base64::engine::GeneralPurpose;
use base64::engine::general_purpose::NO_PAD;

let mut checksum = None;

Expand Down Expand Up @@ -229,8 +229,8 @@ impl<const LEN: usize> Baid64Display<LEN> {
impl<const LEN: usize> Display for Baid64Display<LEN> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
use base64::alphabet::Alphabet;
use base64::engine::general_purpose::NO_PAD;
use base64::engine::GeneralPurpose;
use base64::engine::general_purpose::NO_PAD;

if (self.prefix && !f.sign_minus()) || (!self.prefix && f.sign_minus()) {
write!(f, "{}:", self.hri)?;
Expand Down

0 comments on commit 5c1ca1a

Please sign in to comment.