2

What code in c# produces identical results to CHECKSUM() in TSQL?

I was able to port BINARY_CHECKSUM to c# using this link.

Is there similar way to port CHECKSUM() too?


For example, the TSQL

SELECT CHECKSUM('12')

outputs,

2262

What c# code would produce the same result, for this example and all other possible inputs?

Jodrell
  • 34,946
  • 5
  • 87
  • 124
  • check the following link: [Calculate MD5 checksum for a file](http://stackoverflow.com/questions/10520048/calculate-md5-checksum-for-a-file) – user1666620 Jul 01 '15 at 10:57
  • 5
    Do you mean "equivalent" as "performs the same job" or "given the same input data, both the C# code and CHECKSUM will produce identical outputs" – Damien_The_Unbeliever Jul 01 '15 at 10:58
  • @Damien_The_Unbeliever , by "equivalent" i meant should produce identical output. – Jitendra Singh Rathor Jul 02 '15 at 07:25
  • Duplicate of http://stackoverflow.com/questions/18877523/sqlserver-checksum-in-c-sharp – Mitch Jul 02 '15 at 07:35
  • @JitendraRathor I've edited your question to match your comments. Now, this question is an exact duplicate. Please don't ask duplicates. http://stackoverflow.com/questions/18877523/sqlserver-checksum-in-c-sharp – Jodrell Jul 02 '15 at 07:45

1 Answers1

0

HASHBYTES()

Returns the MD2, MD4, MD5, SHA, SHA1, or SHA2 hash of its input in SQL Server.

Anon
  • 10,660
  • 1
  • 29
  • 31
  • are you suggesting `HASHBYTES` as an alternative to `CHECKSUM` that can be easily mirrored in c#? What c# code would do that? – Jodrell Jul 02 '15 at 07:42
  • I agree except that HASHBYTES has an 8000 byte limit in older versions of Sql Server and CHECKSUM doesn't. – codeConcussion May 31 '17 at 14:27