MCPcopy Create free account
hub / github.com/echQoQ/RustSL / dbj2_hash

Function dbj2_hash

RustVEHSyscalls/src/utils.rs:85–106  ·  view source on GitHub ↗

Computes the DJB2 hash for the given buffer

(buffer: &[u8])

Source from the content-addressed store, hash-verified

83
84/// Computes the DJB2 hash for the given buffer
85pub fn dbj2_hash(buffer: &[u8]) -> u32 {
86 let mut hsh: u32 = 5381;
87 let mut iter: usize = 0;
88 let mut cur: u8;
89
90 while iter < buffer.len() {
91 cur = buffer[iter];
92
93 if cur == 0 {
94 iter += 1;
95 continue;
96 }
97
98 if cur >= ('a' as u8) {
99 cur -= 0x20;
100 }
101
102 hsh = ((hsh << 5).wrapping_add(hsh)) + cur as u32;
103 iter += 1;
104 }
105 hsh
106}
107
108/// Calculates the length of a C-style null-terminated string.
109pub fn get_cstr_len(pointer: *const char) -> usize {

Callers 2

ldr_module_infoFunction · 0.85
get_ssn_by_nameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected