-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Behavioural bug of crypto.sha256.Digest.checksum
and maybe other crypto hashing
#19696
Comments
I think, this bug has been fixed, we can close this issue now. |
Even with latest version of |
import crypto.sha256
fn main() {
s := 'sha256 this string'.bytes()
dump(s.hex())
mut d1 := sha256.new()
o1 := d1.sum(s)
dump(o1.hex())
mut d2 := sha256.new()
n := d2.write(s)!
dump(n)
o2 := d2.sum([]u8{})
o3 := d2.sum([]u8{})
dump(o2.hex())
dump(o3.hex())
} @JalonSolov , Is this the code? |
Could you give me some details about your environment? I'll try to reproduce it, thanks, @JalonSolov |
produces output
is it should not change ? i dont know comparable of golang of |
I got the code from the playground link from the issue opening comment, which is what @blackshirt pasted just above. |
Uh-huh, I'll investigate about checksum. If necessary, I'll supplement PR :) |
Describe the bug
Its based my question on discord channel, at here. so, i'm going to refer to example of golang version of sha256 hash calculation. Its available as en example on golang playground at here.
If we run this example, the output seem like this:
Lets the v version of this at play.vosca.dev here...correct me if i'm wrong.
if we run this example, we get output
if we compare both of them, first Digest by call to
.sum(bytes_input)
directyly produces the same output with go version.but, the second Digest, with write call and then sum (or checksum) ..differs after the first sum/checksum ...only first cheksum is matching with go version.
On the golang side, multiples call to
.Sum(nil)
or with empty bytes after.Write
call ..does not change current hash output, its slightly differ with v versionReproduction Steps
See above link and description
Expected Behavior
I think it should produce same behaviour with go version, multiple calls to .checksum() should not change current hash state..its should be changed by .write(bytes_input) call
Current Behavior
Its slightly produces different output with go version
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.2 fae46a8
Environment details (OS name and version, etc.)
Os Windows
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: