Skip to content

Commit

Permalink
Bumped to 0.5.0, hashing shortened to CRC32/Base64
Browse files Browse the repository at this point in the history
  • Loading branch information
sfisol committed Mar 1, 2024
1 parent 4633c33 commit 7177af0
Show file tree
Hide file tree
Showing 20 changed files with 348 additions and 300 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<!-- markdownlint-configure-file { "no-duplicate-heading": { "siblings_only": true } } -->

<!-- markdownlint-disable-next-line first-line-h1 -->
## 0.5.0 - Unreleased

### Changed

* Hashing of bundled files shortened from SHA256 to CRC64/Base64 to have file names shorter

## 0.4.3 - 2024-02-28

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions crates/vertigo-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vertigo-cli"
version = "0.4.3"
version = "0.5.0"
authors = ["Grzegorz Szeliga <[email protected]>", "Michał Pokrywka <[email protected]>"]
description = "Reactive Real-DOM library with SSR for Rust - packaging/serving tool"
categories = ["command-line-utilities", "development-tools", "development-tools::build-utils", "wasm", "web-programming"]
Expand All @@ -19,10 +19,11 @@ path = "src/main.rs"
[dependencies]
axum = { version = "0.6.20", features = ["macros"] }
axum-extra = "0.8.0"
base64 = "0.21"
clap = { version = "4.0", features = ["derive"] }
crc = "3.0"
env_logger = "0.11"
futures = "0.3.26"
hex = "0.4"
html-escape = "0.2"
include_dir = "0.7"
log = "0.4"
Expand All @@ -32,7 +33,6 @@ poem = { version = "1.3.59", features = ["sse"] }
reqwest = "0.11.14"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0"
sha2 = "0.10"
tokio = { version = "1.25", features = ["full"] }
tokio-stream = "0.1"
tower-http = { version = "0.4", features = ["fs"] }
Expand Down
19 changes: 11 additions & 8 deletions crates/vertigo-cli/src/build/wasm_path.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use sha2::{Sha256, Digest};
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _};
use crc::{Crc, CRC_64_ECMA_182};
use std::{path::PathBuf, io::ErrorKind};

#[derive(Debug)]
Expand Down Expand Up @@ -92,17 +93,19 @@ impl WasmPath {
}
}

const CRC: Crc<u64> = Crc::<u64>::new(&CRC_64_ECMA_182);

pub fn get_hash(data: &[u8]) -> String {
// create a Sha256 object
let mut hasher = Sha256::new();
let mut hasher = CRC.digest();
hasher.update(data);
let result = hasher.finalize();

hex::encode(&result[..])
URL_SAFE_NO_PAD.encode(hasher.finalize().to_be_bytes())
}

#[test]
fn test_hash() {
let ddd = get_hash("vertigo".as_bytes());
assert_eq!(ddd, "e5a559c8ce04fb73d98cfc83e140713600c1134ac676d0b4debcc9838c09e2d7");
let ddd1 = get_hash("vertigo1".as_bytes());
let ddd2 = get_hash("vertigo1".as_bytes());
let ddd3 = get_hash("vertigo2".as_bytes());
assert_eq!(ddd1, ddd2);
assert_ne!(ddd2, ddd3);
}
2 changes: 1 addition & 1 deletion crates/vertigo-cli/src/new/template/Cargo.toml_
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]

[dependencies]
vertigo = "0.4"
vertigo = "0.5"
10 changes: 5 additions & 5 deletions crates/vertigo-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vertigo-macro"
version = "0.4.3"
version = "0.5.0"
authors = ["Grzegorz Szeliga <[email protected]>", "Michał Pokrywka <[email protected]>"]
description = "Reactive Real-DOM library with SSR for Rust - macros"
edition = "2021"
Expand All @@ -11,14 +11,14 @@ name = "vertigo_macro"
proc-macro = true

[dependencies]
base64 = "0.21"
crc = "3.0"
itertools = "0.12"
pest = "2.5"
pest_derive = "2.1"
pkg-version = "1"
proc-macro2 = "1.0"
proc-macro-error = "1.0"
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features=["full"] }
itertools = "0.12"
syn-rsx = "0.8"
sha2 = "0.10"
hex = "0.4"
Loading

0 comments on commit 7177af0

Please sign in to comment.