Last active
August 27, 2024 13:59
-
-
Save SndrSchnklshk/9b33757c69eb6d08260921df526dc463 to your computer and use it in GitHub Desktop.
Generate a simple checksum in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Generates a Checksum | |
| // EXAMPLE: Input="Hello World!!" -> Output="5E" | |
| public static string GenerateChecksum(string input) | |
| { | |
| byte[] bytes = Encoding.ASCII.GetBytes(input); | |
| byte result = 0; | |
| foreach (byte c in bytes) | |
| result += c; | |
| result &= 0xff; | |
| return result.ToString("X2"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment