CheckSum..::..Generate Method (String)
Generates a cryptographic hash for a given string using the MD5 algorithm. This method is designed
to convert the input text into a hash value represented as an integer. If the input string is null
or empty, 0 will be returned.
Namespace:
Walter.CypherAssembly: Walter.Cypher (in Walter.Cypher.dll)
Syntax
[MethodImplAttribute] [FeatureTagsAttribute] public static int Generate( string source )
Parameters
- source
- Type: String
The input string to hash.
Return Value
An integer representing the MD5 hash of the input string, or 0 if the input is null or empty.Remarks
Examples
Sample Test method
[TestMethod()] public void GenerateSymulateStringIntegretyTest() { const string manipolationChecked = "Select * from settings where [Administrator] = 1"; var expect = CheckSum.Generate(manipolationChecked); string sqlInject = $"{manipolationChecked} or 1=1"; var isSafe=CheckSum.Validate(manipolationChecked, expect); Assert.IsTrue(isSafe); var isWrong=CheckSum.Validate(sqlInject, expect); Assert.IsFalse(isWrong); }