A git commit hash (the 40-character string like a94a8fe5cc...) is a SHA-1 digest of the commit's content — its tree, parent commit(s), author, and message — not of your source files directly. Two commits with identical content and metadata produce the identical hash, which is how git detects that a commit already exists.
Git has historically used SHA-1, the same algorithm in the tool on this page, though the project has been migrating toward SHA-256 support for new repositories given SHA-1's known collision weaknesses (see the SHA-1 generator page for more on that). Most repositories in the wild are still SHA-1-based.