Skip to content
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

different results between julia 1.10 vs osx builtin #16

Closed
jonalm opened this issue Jan 4, 2024 · 2 comments
Closed

different results between julia 1.10 vs osx builtin #16

jonalm opened this issue Jan 4, 2024 · 2 comments

Comments

@jonalm
Copy link

jonalm commented Jan 4, 2024

consider the following (on mac M2)

> echo "asdpfginpqvwen" >> foo
> md5 foo
MD5 (foo) = 610d6da0969779be0e9c6c1386218660

Now opening julia 1.10 and MD5 v0.2.2, I get

julia> using MD5
julia> bytes2hex(md5("foo"))
"acbd18db4cc2f85cedef654fccc4a4d8"

How come these results are different?

@BonelessPi
Copy link

In your first code block, you run the command md5 foo which reads the content of the file "foo" and runs the MD5 hash of its contents. In addition, I believe the echo command also adds a newline character to the end of the input. On my machine the hash seems to match your expected output:

julia> bytes2hex(md5("asdpfginpqvwen\n"))
"610d6da0969779be0e9c6c1386218660"

In the second code block, you use julia to run the MD5 hash of the string "foo". In order to run the hash on the contents, you would want something like:

open("foo") do f
     bytes2hex(md5(f))
end

@oxinabox oxinabox closed this as completed Jan 5, 2024
@jonalm
Copy link
Author

jonalm commented Jan 5, 2024

Many thanks @BonelessPi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants