StringExtensions..::..AsShaHash Method (String, HashMethod, Int32, AsHashSubsetLocation)
Generate hash of a given string using SHA methods
Namespace:
SystemAssembly: Walter (in Walter.dll)
Syntax
public static string AsShaHash( string plainText, HashMethod hashing, int byteCount, AsHashSubsetLocation location )
Parameters
- plainText
- Type: String
The text to compute the hash for
- hashing
- Type: System..::..HashMethod
the hashing method to use
- byteCount
- Type: Int32
Set the number of bytes to take from the hashed when generating the string
- location
- Type: Walter..::..AsHashSubsetLocation
set the location from where to take the value from
Return Value
Hash value of a given stringRemarks
Examples
Make a password from a string
var creditCard="4500-000-000-000"; var password= creditCard.AsShaHash(HashMethod.SHA256, 8); var encryptionHelper = new Walter.SymmetricEncryption(password); /// var cypher= encryptionHelper.EncryptString(plain); if(string.IsNullOrEmpty(cypher)) { throw new ApplicationException("Encryption generate null"); } var copy= encryptionHelper.DecryptString(cypher); /// if(!string.Equals(plain, copy, StringComparison.Ordinal)) { throw new Exception($"Plain {plain} and copy {copy} should be the same"); }

