use crypto::sha256;
use encoding::hex;
use hash;
use io;
use os;
use fmt;
export fn main() void = {
const hash = sha256::sha256();
const file = os::open(os::args[1])!;
io::copy(&hash, file)!;
let sum: [sha256::SIZE]u8 = [0...];
hash::sum(&hash, sum);
hex::encode(os::stdout, sum)!;
fmt::println()!;
};
Save this file as hash.ha, install the hare compiler and standard library and then compile by running hare build -o hash hash.ha in the same directory. Then you can run ./hash [file] to get the hash <3« Back to the Da Slop Pit Forum
Small file hasher written in hare
Hi :)
I wrote a quick file hasher in hare. Run the program and pass whatever file you want hashed as an argument and it'll make the sha256 hash for it and print it out for you <3
Be careful! If you don't add a file as an argument then you get a core dump from the array being out of bounds! :0