WALTER | Workable Algorithms for Location-aware Transmission, Encryption Response

CheckSum..::..Generate Method (String, HashMethod)

Generates a cryptographic hash for a given string using a specified hashing algorithm. If the input string is null, 0 will be returned.

Namespace:  Walter.Cypher
Assembly:  Walter.Cypher (in Walter.Cypher.dll)

Syntax


[MethodImplAttribute]
[FeatureTagsAttribute]
public static int Generate(
	string source,
	HashMethod method
)

Parameters

source
Type: String
The input string to hash.
method
Type: HashMethod
The hashing algorithm to use, specified by the [HashMethod] enum.

Return Value

An integer representation of the hash computed from the input string using the specified algorithm, or 0 if the input is null.

Remarks


This method provides flexibility in selecting the hashing algorithm for generating the hash. It supports SHA256, SHA384, SHA512, and SHA1, accommodating different levels of security and hash lengths. The choice of algorithm impacts the hash length and the level of security, with SHA256, SHA384, and SHA512 offering stronger security than SHA1. Usage of SHA1 is discouraged for security-critical applications due to known vulnerabilities. It is recommended to use SHA256 or higher for enhanced security. Note: The method returns an integer representation of the hash which might not directly correspond to the usual hexadecimal string representation. For cryptographic purposes and verifications where the exact hash value is critical, consider using the full string representation of the hash.

Examples


More secure option than the MD5 methodGenerate(String)
use SHA256 to compute a hash
int hashValue = CheckSum.Generate("example input", HashMethod.SHA256);