I am no expert on this matter, but what I have found is a comment on another thread that gave me an insight on what is going on, so I will just post it here:
"What it is really happenning is that the SHA256 returns a 256-bit hash value. So what you're printing is those bytes as if they were characters and their respective character values is all that gibberish.
What the online tool is returning you is the representation of that value in hexadecimal format.
Notice that you're getting, (with the tool) 64 bytes IE 64 characters when 256-bit is equal to 32 bytes (32 characters you may think). That is because to represent a whole byte in hexadecimal format 2 characters are needed. 4 most significant bits take one character and the other less significant bits take another one."
Basically from what I understand both are correct, but are parsed differently.
You can see here is that the latter one you posted is in hexadecimal code, which is not what any sha256 hashing algorithms actually returns when in code.
Try this online conversion tool and you will see that it gives you the same as your first one (that method gives you back).
Finally you should rely on the format that is returned inside the code (from the function call) since it will always be correct even when using other libraries with the same hashing algorithm.
Hope this helps