diff options
Diffstat (limited to 'doc/classes/HashingContext.xml')
-rw-r--r-- | doc/classes/HashingContext.xml | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/doc/classes/HashingContext.xml b/doc/classes/HashingContext.xml index 7c2be6f817..5223cbf52f 100644 --- a/doc/classes/HashingContext.xml +++ b/doc/classes/HashingContext.xml @@ -8,7 +8,7 @@ The [enum HashType] enum shows the supported hashing algorithms. [codeblocks] [gdscript] - const CHUNK_SIZE = 102 + const CHUNK_SIZE = 1024 func hash_file(path): # Check that file exists. @@ -32,17 +32,16 @@ public void HashFile(string path) { - var ctx = new HashingContext(); - var file = new File(); - // Start a SHA-256 context. - ctx.Start(HashingContext.HashType.Sha256); // Check that file exists. - if (!file.FileExists(path)) + if (!FileAccess.FileExists(path)) { return; } + // Start a SHA-256 context. + var ctx = new HashingContext(); + ctx.Start(HashingContext.HashType.Sha256); // Open the file to hash. - file.Open(path, File.ModeFlags.Read); + using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read); // Update the context after reading each chunk. while (!file.EofReached()) { @@ -51,8 +50,7 @@ // Get the computed hash. byte[] res = ctx.Finish(); // Print the result as hex string and array. - - GD.PrintT(res.HexEncode(), res); + GD.PrintT(res.HexEncode(), (Variant)res); } [/csharp] [/codeblocks] |