Returns the SHA1 hash of a
local hw_hash = hash.sha1("Hello World");
printf("SHA1 for \'Hello World\' is: %s\n", hw_hash);
printf("\nEnter a hash for comparison>");
local inp = io.read("*l");
if( inp == hw_hash ) then
printf("Congrats! You entered the correct hash.\n");
else
printf("Nope. Wrong hash.\n");
end
--[[ This snippet will display the hash for the string "Hello World"
If the user enters 0a4d55a8d778e5022fab701977c5d840bbc486d0 when prompted,
it will display the congrats line, otherwise it informs them the hash was wrong.
--]]
Exactly like hash.sha1() except that it computes the hash for a given file rather than an input string.
Page last updated at 2018-09-25 20:47:42
Copyright 2024