This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
fn hash_string_djb2(comptime string: []const u8) u64 { | |
var hash: u64 = 5381; | |
inline for (string) |chr| { | |
hash = ((hash << 5) + hash) + chr; | |
} | |
return hash; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
fn stack_string(comptime string: []const u8) [string.len]u8{ | |
var new_string: [string.len]u8 = undefined; | |
inline for (string) |chr, idx|{ | |
new_string[idx] = chr; | |
} | |
return new_string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
fn _x(comptime string: []const u8) [string.len]u8 { | |
var encrypted_string: [string.len]u8 = undefined; | |
var decrypted_string: [string.len]u8 = undefined; | |
inline for (string) |chr, idx| { | |
encrypted_string[idx] = chr ^ 0x99; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const RndGen = std.rand.DefaultPrng; | |
fn rand_at_comptime() u32 { | |
var rnd = RndGen.init(1337); | |
var a = rnd.random().int(u32); | |
return a; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
fn encrypt(comptime string: []const u8) []const u8{ | |
var new_string: [string.len]u8 = undefined; | |
for (string) |chr, idx|{ | |
new_string[idx] = chr ^ 0xff; | |
} | |
return &new_string; |