![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Allespro |
Hello, please help.
I need to create hash of string, ex.
var gen_sha256(str):
...
print(gen_sha256("godot"))
should print:
c629695bba3cbb3a0fb0eab3a7746c72836fecb938073f483627bb144ebbfeb6
HashingContext is not working, says:
Identifier 'HashingContext' is not declared in the current scope.
Your error is in whoever is using HashingContext
so, can you make a snippet of that part of the code, probably your gen_sha256
method. Also the docs seem pretty clear cut on how to do it.
tastyshrimp | 2019-12-29 22:48
Error with that:
var ctx = HashingContext.new()
I use extends Node
like in docs. Also I have no gen_sha256
, just want to create.
Allespro | 2019-12-30 18:21
I took a deeper look into the docs and it seems that the String
class has a sha256_text
method that does the hashing for you. So all you would need to do is call it:
func sha_256(str: String) -> String:
return string.sha256_text()
tastyshrimp | 2019-12-30 20:42
Yeah! That works, thanks a lot!
How can I upvote you?
Allespro | 2020-01-01 15:51
I added an actual answer so you can select it.
tastyshrimp | 2020-01-01 16:06