[−][src]Function fuzzyhash::fuzzyhash
#[no_mangle]pub unsafe extern "C" fn fuzzyhash(buf: *const u8, length: usize) -> *mut c_char
Returns the fuzzy hash of arbitrary data. This method provides better FFI compatibility.
Arguments
buf
- a pointer to the array containing the data to hashlength
- length of buf
Safety
This is function is unsafe
as it is intended to read a string from FFI
Example
use fuzzyhash::{fuzzyhash}; use std::ffi::CString; let data = "this is our test data!".to_string(); let hash = unsafe { CString::from_raw(fuzzyhash(data.as_bytes().as_ptr(), data.len())) }; let hash = hash.into_string().unwrap(); println!("Fuzzy Hash: {}", hash); assert_eq!(hash, "3:YKKGhR0tn:YRGRmn");