Git adds a header ("blob ", the length, then null) before calculating the SHA-1. See this blog post for how to emulate the calculation outside git.