浏览代码

Attempt even dumber hashing mechanism

Jonathan Kelley 1 年之前
父节点
当前提交
e02e41d6f1
共有 2 个文件被更改,包括 10 次插入7 次删除
  1. 9 6
      packages/interpreter/build.rs
  2. 1 1
      packages/interpreter/src/js/hash.txt

+ 9 - 6
packages/interpreter/build.rs

@@ -1,4 +1,4 @@
-use std::{collections::hash_map::DefaultHasher, hash::Hasher, process::Command};
+use std::process::Command;
 
 fn main() {
     // If any TS changes, re-run the build script
@@ -31,12 +31,15 @@ fn hash_ts_files() -> u128 {
         include_str!("src/ts/core.ts"),
     ];
 
-    for file in files.iter() {
-        let mut hasher = DefaultHasher::new();
-        hasher.write(file.as_bytes());
-        out += hasher.finish() as u128;
+    // Let's make the dumbest hasher by summing the bytes of the files
+    // The location is multiplied by the byte value to make sure that the order of the bytes matters
+    let mut idx = 0;
+    for file in files {
+        for byte in file.bytes() {
+            idx += 1;
+            out += (byte as u128) * (idx as u128);
+        }
     }
-
     out
 }
 

+ 1 - 1
packages/interpreter/src/js/hash.txt

@@ -1 +1 @@
-31613791829349842071
+12705686530