Created
January 20, 2023 21:17
-
-
Save Reijaff/705051174717949168a6ded88dbf7bf9 to your computer and use it in GitHub Desktop.
primitive compile time string obfuscation in zig, stack strings, position independent code
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; | |
| } | |
| for (encrypted_string) |chr, idx| { | |
| decrypted_string[idx] = chr ^ 0x99; | |
| } | |
| return decrypted_string; | |
| } | |
| pub fn main() !void { | |
| const stdout = std.io.getStdOut().writer(); | |
| try stdout.print("{s}\n", .{_x("hello my dear friend")}); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment