Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FNV-1a #180

Closed
soundsnow opened this issue Dec 7, 2022 · 5 comments
Closed

FNV-1a #180

soundsnow opened this issue Dec 7, 2022 · 5 comments
Assignees
Labels
feature Feature request takes time for resolve Issues with problems/questions that take time for resolve/answer
Projects

Comments

@soundsnow
Copy link

https://www.richwhitehouse.com/jaguar/index.php?content=compat
https://en.m.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
Q: Why are you using FNV-1a everywhere? What about hash collisions?! WHAT ABOUT MY BABY?!
A: FNV-1a is very fast and convenient, and we're far less likely to run into a hash collision with 64-bit FNV-1a. With a software library as small as the Jaguar's, even accounting for homebrew, you'd have to be actively trying to produce a collision.

@fartem fartem self-assigned this Dec 7, 2022
@fartem fartem added the takes time for resolve Issues with problems/questions that take time for resolve/answer label Dec 7, 2022
@fartem fartem mentioned this issue Jul 19, 2023
@fartem fartem added the feature Feature request label Jul 20, 2023
@ManishDait
Copy link
Contributor

Hi @fartem I am working on this issue.

@fartem fartem assigned ManishDait and unassigned fartem Jul 22, 2023
@fartem fartem added this to In progress in 3.7.2 Jul 22, 2023
@ManishDait
Copy link
Contributor

@fartem FNV-1a comes in 32-, 64-, 128-, 256-, 512-, and 1024-bit variants. which one to implement.

@ManishDait
Copy link
Contributor

public final class Fnv1a {
  private static  final long FNV_OFFSET_BASIS = 0xcbf29ce484222325L;
  private static final long FNV_PRIME = 0x00000100000001B3L;

  private long hash = FNV_OFFSET_BASIS;

  public void update(byte[] b) {
    for(byte i : b){
      hash = hash ^ i;
      hash = hash * FNV_PRIME;
    }
  }
  public String getHash() {
    return Long.toHexString(hash);
  }
}

Implementation for 64 bit.

@fartem
Copy link
Member

fartem commented Jul 23, 2023

@ManishDait, if you can - implement all variants.

@ManishDait
Copy link
Contributor

@ManishDait, if you can - implement all variants.

Yeah

@fartem fartem moved this from In progress to Done in 3.7.2 Jul 27, 2023
@fartem fartem closed this as completed Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request takes time for resolve Issues with problems/questions that take time for resolve/answer
Projects
No open projects
3.7.2
  
Done
Development

No branches or pull requests

3 participants