Jump to content




SHA256 how to use


1 reply to this topic

#1 danielsv03

  • Members
  • 66 posts
  • LocationMinecraft world

Posted 11 June 2017 - 05:02 PM

Hi so i wanted to do some password encryption system and i found sha256.. But i don't know how to uses it..
So any help would be useful
I'm looking for
1. how to convert string into hash
2. compair hash and string
3. koner hash to string again.
4. etc

Thanks :)

#2 valithor

  • Members
  • 1,053 posts

Posted 11 June 2017 - 06:23 PM

Assuming you are using anavrins sha256 api from: https://pastebin.com/6UV4qfNF

One note before I start explaining. sha256 is a hash not encryption, which means it is one way. You can turn a string into a hash, but not a hash back into the original string.

1:
--# load the api using os.loadAPI(filename), where filename is the name of the file
local stringToHash = "hello world"
local hashedString = filename.digest(stringToHash)

2:
You can't compare them directly, instead you hash the string you want to compare to the hash and compare the hashes
local hashedString = digest("hello world")
local stringToCompare = "hello world"
if digest(stringToCompare) == hashedString then
  --# they are equal
end

3: You can't by definition of a hash. A hash cannot be "decrypted" by definition.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users