SHA1 hashes not matching between my Rails and Cocoa apps

前端 未结 1 1744
花落未央
花落未央 2021-02-13 10:47

I have a Cocoa app send some data along with a SHA1 hash of that data to a Rails app which verifies that the data and the hash match, but they do not.

To be sure I have

1条回答
  •  灰色年华
    2021-02-13 11:34

    Found the error, stupid little thing:

    -CC_SHA1([self bytes], CC_SHA1_DIGEST_LENGTH, hashBytes);
    +CC_SHA1([self bytes], [self length], hashBytes);
    

    I sent the length of the digest instead of the length of the data. Don't know how I could've made such a mistake – and then overlook it for hours.

    0 讨论(0)
提交回复
热议问题