mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
forgot to add a file
This commit is contained in:
parent
84ada3c62a
commit
6cfdd67cf0
20
src/data.zig
Normal file
20
src/data.zig
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const c = @cImport({
|
||||||
|
@cInclude("neonucleus.h");
|
||||||
|
});
|
||||||
|
|
||||||
|
pub export fn nn_data_crc32(inBuf: [*]const u8, len: usize, outBuf: [*]u8) void {
|
||||||
|
var digest = std.hash.Crc32.hash(inBuf[0..len]);
|
||||||
|
digest = std.mem.nativeToLittle(u32, digest);
|
||||||
|
|
||||||
|
const digestBuf: [4]u8 = @bitCast(digest);
|
||||||
|
std.mem.copyForwards(u8, outBuf[0..4], &digestBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub export fn nn_data_md5(inBuf: [*]const u8, len: usize, outBuf: [*]u8) void {
|
||||||
|
std.crypto.hash.Md5.hash(inBuf[0..len], @ptrCast(outBuf), .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub export fn nn_data_sha256(inBuf: [*]const u8, len: usize, outBuf: [*]u8) void {
|
||||||
|
std.crypto.hash.sha2.Sha256.hash(inBuf[0..len], @ptrCast(outBuf), .{});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user