0

I'm trying to find a better data type for storing SHA256 hash, right now I'm using string, and I'm thinking of switching to byte32 but considering it I don't know if this is really a step in the right direction. Is there a better data type for storing a sha256 hash?

This sha hash is not generated by sha256() so there is not a 0x prefix already affixed to it which is why I am concerned about adding those extra bytes instead of just leaving it as a string

1

Use bytes32.

not generated by sha256() so there is not a 0x prefix.

You didn't say where it comes from. I'll assume from outside the contract. Use a bytes32 function argument to receive it. Formatting the input correctly will be a client-side concern.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.