IGLib  1.5
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
IG.Crypto.UtilCrypto Class Reference

Basic Cryptographic utilities. More...

Classes

class  ConstCrypto
 Contains constants for cryptographic operations from shell functions. More...
 

Static Public Member Functions

static int GetHashLengthBytes (HashType hashType)
 Returns length of the hash value, in bytes, for the specified hash algorithm. More...
 
static int GetHashLengthHex (HashType hashType)
 Returns length of the HEXADECIMAL hash string for the specified hash algorithm. More...
 
static HashAlgorithm CreateHashAlgorithm (HashType hashType)
 Returns the appropriate hash algorithm according to the specified hash type, or null if the type is not recognized or the method is not implemented for that type. More...
 
static HashType GetHashType (string typeString)
 
static string GetHashType (HashType hashType)
 Returns standard string representation of the specified hash type. More...
 
static string HashTypeToString (HashType hashType)
 Returns standard string representation of the specified hash type. More...
 
static void ParseHashFile (string filePath, ref List< string[]> hashList)
 Parses the file containing hash values of one or more files, and adds the parsed pairs {hash, filePath} to the specified list. More...
 
static void ParseHashFileString (string str, ref List< string[]> hashList)
 Parses the string containing hash values of one or more files, and adds the parsed pairs {hash, filePath} to the specified list. More...
 
static string GetStringHash (string stringToHash, HashType hashType)
 Computes and returns the hash string of the specified kind of the specified string. More...
 
static string GetStringHashMd5 (string stringToHash)
 Computes and returns the SHA1 hash string of the specified string. More...
 
static string GetStringHashSha1 (string stringToHash)
 Computes and returns the SHA1 hash string of the specified string. More...
 
static string GetStringHashSha256 (string stringToHash)
 Computes and returns the SHA256 hash string of the specified string. More...
 
static string GetStringHashSha512 (string stringToHash)
 Computes and returns the SHA512 hash string of the specified string. More...
 
static bool CheckStringHash (string stringToCheck, string hashValue, HashType hashType)
 Chechs the specified type of hash value of a string. More...
 
static HashType CheckStringHashSupportedTypes (string stringToCheck, string hashValue)
 Chechs all supported types of hash value of a string. More...
 
static bool CheckStringHashMd5 (string stringToCheck, string hashValue)
 Checks whether the specified MD5 hash value matches the actual hash value of the specified string. More...
 
static bool CheckStringHashSha1 (string stringToCheck, string hashValue)
 Checks whether the specified SHA-1 hash value matches the actual hash value of the specified string. More...
 
static bool CheckStringHashSha256 (string stringToCheck, string hashValue)
 Checks whether the specified SHA-256 hash value matches the actual hash value of the specified string. More...
 
static bool CheckStringHashSha512 (string stringToCheck, string hashValue)
 Checks whether the specified SHA-512 hash value matches the actual hash value of the specified string. More...
 
static string GetFileHash (string filePath, HashType hashType)
 Computes and returns the hash string of specified type of the specified stream. More...
 
static string GetFileHashMd5 (string filePath)
 Computes and returns the MD5 hash string of the specified stream. More...
 
static string GetFileHashSha1 (string filePath)
 Computes and returns the SHA1 hash string of the specified stream. More...
 
static string GetFileHashSha256 (string filePath)
 Computes and returns the SHA256 hash string of the specified stream. More...
 
static string GetFileHashSha512 (string filePath)
 Computes and returns the SHA512 hash string of the specified stream. More...
 
static string GetHash (Stream stream, HashType hashType)
 Computes and returns the hash string of specified type of the specified stream. More...
 
static string GetHashMd5 (Stream stream)
 Computes and returns the MD5 hash string of the specified stream. More...
 
static string GetHashSha1 (Stream stream)
 Computes and returns the SHA1 hash string of the specified stream. More...
 
static string GetHashSha256 (Stream stream)
 Computes and returns the SHA256 hash string of the specified stream. More...
 
static string GetHashSha512 (Stream stream)
 Computes and returns the SHA512 hash string of the specified stream. More...
 
static bool CheckFileHash (string filePath, string hashValue, HashType hashType)
 Chechs the specified type of hash value of a file. More...
 
static HashType CheckFileHashSupportedTypes (string filePath, string hashValue)
 Chechs all supported types of hash value of a file. More...
 
static bool CheckFileHashMd5 (string filePath, string hashValue)
 Checks whether the specified MD5 hash value matches the actual hash value of the specified file. More...
 
static bool CheckFileHashSha1 (string filePath, string hashValue)
 Checks whether the specified SHA-1 hash value matches the actual hash value of the specified file. More...
 
static bool CheckFileHashSha256 (string filePath, string hashValue)
 Checks whether the specified SHA-256 hash value matches the actual hash value of the specified file. More...
 
static bool CheckFileHashSha512 (string filePath, string hashValue)
 Checks whether the specified SHA-512 hash value matches the actual hash value of the specified file. More...
 

Detailed Description

Basic Cryptographic utilities.

$A Igor Apr10;

Member Function Documentation

static int IG.Crypto.UtilCrypto.GetHashLengthBytes ( HashType  hashType)
inlinestatic

Returns length of the hash value, in bytes, for the specified hash algorithm.

-1 is returned if the length is not known.

Parameters
hashTypeType of the hashing algorithm.
static int IG.Crypto.UtilCrypto.GetHashLengthHex ( HashType  hashType)
inlinestatic

Returns length of the HEXADECIMAL hash string for the specified hash algorithm.

-1 is returned if the length is not known.

Parameters
hashTypeType of the hashing algorithm.
static HashAlgorithm IG.Crypto.UtilCrypto.CreateHashAlgorithm ( HashType  hashType)
inlinestatic

Returns the appropriate hash algorithm according to the specified hash type, or null if the type is not recognized or the method is not implemented for that type.

Parameters
hashTypeSpecification of the hash algorthm type.
static HashType IG.Crypto.UtilCrypto.GetHashType ( string  typeString)
inlinestatic
static string IG.Crypto.UtilCrypto.GetHashType ( HashType  hashType)
inlinestatic

Returns standard string representation of the specified hash type.

Does the same as HashTypeToString.

Parameters
hashTypeHash type whose string representation is returned.
static string IG.Crypto.UtilCrypto.HashTypeToString ( HashType  hashType)
inlinestatic

Returns standard string representation of the specified hash type.

Parameters
hashTypeHash type whose string representation is returned.
static void IG.Crypto.UtilCrypto.ParseHashFile ( string  filePath,
ref List< string[]>  hashList 
)
inlinestatic

Parses the file containing hash values of one or more files, and adds the parsed pairs {hash, filePath} to the specified list.

File must be in the standard format where each line contains a hash value and the path to the corresponding file separated from hash value by one or more spaces.

List is allocated if necessary. Eventual existent pairs on the list are not affected.

Parameters
filePathPath to the file that is parsed.
hashListList to which which parsed pairs {hash, filePath} are added in form of arrays of 2 strings.

Example contents of the file:

595f44fec1e92a71d3e9e77456ba80d1 filetohashA.txt

71f920fa275127a7b60fa4d4d41432a3 filetohashB.txt

43c191bf6d6c3f263a8cd0efd4a058ab filetohashC.txt

/remarks>

Referenced by IG.Script.ScriptAppBase.CryptoFunctionCheckSum().

static void IG.Crypto.UtilCrypto.ParseHashFileString ( string  str,
ref List< string[]>  hashList 
)
inlinestatic

Parses the string containing hash values of one or more files, and adds the parsed pairs {hash, filePath} to the specified list.

String must be in the standard format where each line contains a hash value and the path to the corresponding file separated from hash value by one or more spaces.

List is allocated if necessary. Eventual existent pairs on the list are not affected.

Parameters
strString that is parsed.
hashListList to which which parsed pairs {hash, filePath} are added in form of arrays of 2 strings.

Example contents of the string:

595f44fec1e92a71d3e9e77456ba80d1 filetohashA.txt

71f920fa275127a7b60fa4d4d41432a3 filetohashB.txt

43c191bf6d6c3f263a8cd0efd4a058ab filetohashC.txt

/remarks>

static string IG.Crypto.UtilCrypto.GetStringHash ( string  stringToHash,
HashType  hashType 
)
inlinestatic

Computes and returns the hash string of the specified kind of the specified string.

null is returned if the specified hash type is not known or implemented.

Parameters
stringToHashString whose hash string is calculated.
hashTypeSpecifies the type of the hashing algorithm to be used.

Referenced by IG.Script.ScriptAppBase.CryptoFunctionCheckSum().

static string IG.Crypto.UtilCrypto.GetStringHashMd5 ( string  stringToHash)
inlinestatic

Computes and returns the SHA1 hash string of the specified string.

Parameters
stringToHashString whose cryptographic hash is calculated.

Referenced by IG.Forms.HashGeneratorControl.CalculateHashes().

static string IG.Crypto.UtilCrypto.GetStringHashSha1 ( string  stringToHash)
inlinestatic

Computes and returns the SHA1 hash string of the specified string.

Parameters
stringToHashString whose cryptographic hash is calculated.

Referenced by IG.Forms.HashGeneratorControl.CalculateHashes().

static string IG.Crypto.UtilCrypto.GetStringHashSha256 ( string  stringToHash)
inlinestatic

Computes and returns the SHA256 hash string of the specified string.

Parameters
stringToHashString whose cryptographic hash is calculated.

Referenced by IG.Forms.HashGeneratorControl.CalculateHashes().

static string IG.Crypto.UtilCrypto.GetStringHashSha512 ( string  stringToHash)
inlinestatic

Computes and returns the SHA512 hash string of the specified string.

Parameters
stringToHashString whose cryptographic hash is calculated.

Referenced by IG.Forms.HashGeneratorControl.CalculateHashes().

static bool IG.Crypto.UtilCrypto.CheckStringHash ( string  stringToCheck,
string  hashValue,
HashType  hashType 
)
inlinestatic

Chechs the specified type of hash value of a string.

Returns true if the hash value matches the hash value of the string, and false otherwise.

Parameters
stringToCheckString whose hash value is checked.
hashValueSupposed hash value whose correctness is checked.
hashTypeType of the hash value that is checked.
Returns
True if the specified hash hashValue actually matches the hash value of the type hashType of the verified string stringToCheck , or false otherwise.

Referenced by IG.Script.ScriptAppBase.CryptoFunctionCheckSum().

static HashType IG.Crypto.UtilCrypto.CheckStringHashSupportedTypes ( string  stringToCheck,
string  hashValue 
)
inlinestatic

Chechs all supported types of hash value of a string.

Returns the hash type if the hash value matches the hash value of that type of the specified string, or HashType.None if the specified hash value doesn't match the hash value of any supported type of the string.

Parameters
stringToCheckString whose hash value is checked.
hashValueSupposed hash value whose match with the specified string is checked.
Returns
Type of the hash value that matches the specified hash value of the specified string, or HashType.None if the specified hash value doesn't match the hash value of any supported type of the specified string.

Referenced by IG.Forms.HashGeneratorControl.VerifyHash().

static bool IG.Crypto.UtilCrypto.CheckStringHashMd5 ( string  stringToCheck,
string  hashValue 
)
inlinestatic

Checks whether the specified MD5 hash value matches the actual hash value of the specified string.

Returns true if the specified hash value matches the actual hash value of the string, and false otherwise.

Parameters
stringToCheckString whose hash value is checked.
hashValueSupposed hash value whose validity is checked for the specified string.
Returns
True if the specified hash value matches the actual value, false otherwise.
static bool IG.Crypto.UtilCrypto.CheckStringHashSha1 ( string  stringToCheck,
string  hashValue 
)
inlinestatic

Checks whether the specified SHA-1 hash value matches the actual hash value of the specified string.

Returns true if the specified hash value matches the actual hash value of the string, and false otherwise.

Parameters
stringToCheckString whose hash value is checked.
hashValueSupposed hash value whose validity is checked for the specified string.
Returns
True if the specified hash value matches the actual value, false otherwise.
static bool IG.Crypto.UtilCrypto.CheckStringHashSha256 ( string  stringToCheck,
string  hashValue 
)
inlinestatic

Checks whether the specified SHA-256 hash value matches the actual hash value of the specified string.

Returns true if the specified hash value matches the actual hash value of the string, and false otherwise.

Parameters
stringToCheckString whose hash value is checked.
hashValueSupposed hash value whose validity is checked for the specified string.
Returns
True if the specified hash value matches the actual value, false otherwise.
static bool IG.Crypto.UtilCrypto.CheckStringHashSha512 ( string  stringToCheck,
string  hashValue 
)
inlinestatic

Checks whether the specified SHA-512 hash value matches the actual hash value of the specified string.

Returns true if the specified hash value matches the actual hash value of the string, and false otherwise.

Parameters
stringToCheckString whose hash value is checked.
hashValueSupposed hash value whose validity is checked for the specified string.
Returns
True if the specified hash value matches the actual value, false otherwise.
static string IG.Crypto.UtilCrypto.GetFileHash ( string  filePath,
HashType  hashType 
)
inlinestatic

Computes and returns the hash string of specified type of the specified stream.

Parameters
filePathPath to the file whose contents' cryptographic hash is calculated.
hashTypeSpecifies the type of the hashing algorithm to be used.

Referenced by IG.Script.ScriptAppBase.CryptoFunctionCheckSum().

static string IG.Crypto.UtilCrypto.GetFileHashMd5 ( string  filePath)
inlinestatic

Computes and returns the MD5 hash string of the specified stream.

Parameters
filePathPath to the file whose contents' cryptographic hash is calculated.

Referenced by IG.Forms.HashGeneratorControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash().

static string IG.Crypto.UtilCrypto.GetFileHashSha1 ( string  filePath)
inlinestatic

Computes and returns the SHA1 hash string of the specified stream.

Parameters
filePathPath to the file whose contents' cryptographic hash is calculated.

Referenced by IG.Forms.HashGeneratorControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash().

static string IG.Crypto.UtilCrypto.GetFileHashSha256 ( string  filePath)
inlinestatic

Computes and returns the SHA256 hash string of the specified stream.

Parameters
filePathPath to the file whose contents' cryptographic hash is calculated.

Referenced by IG.Forms.HashGeneratorControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash().

static string IG.Crypto.UtilCrypto.GetFileHashSha512 ( string  filePath)
inlinestatic

Computes and returns the SHA512 hash string of the specified stream.

Parameters
filePathPath to the file whose contents' cryptographic hash is calculated.

Referenced by IG.Forms.HashGeneratorControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash().

static string IG.Crypto.UtilCrypto.GetHash ( Stream  stream,
HashType  hashType 
)
inlinestatic

Computes and returns the hash string of specified type of the specified stream.

Parameters
streamStream whose contents' cryptographic hash is calculated.
static string IG.Crypto.UtilCrypto.GetHashMd5 ( Stream  stream)
inlinestatic

Computes and returns the MD5 hash string of the specified stream.

Parameters
streamStream whose contents' cryptographic hash is calculated.
static string IG.Crypto.UtilCrypto.GetHashSha1 ( Stream  stream)
inlinestatic

Computes and returns the SHA1 hash string of the specified stream.

Parameters
streamStream whose contents' cryptographic hash is calculated.
static string IG.Crypto.UtilCrypto.GetHashSha256 ( Stream  stream)
inlinestatic

Computes and returns the SHA256 hash string of the specified stream.

Parameters
streamStream whose contents' cryptographic hash is calculated.
static string IG.Crypto.UtilCrypto.GetHashSha512 ( Stream  stream)
inlinestatic

Computes and returns the SHA512 hash string of the specified stream.

Parameters
streamStream whose contents' cryptographic hash is calculated.
static bool IG.Crypto.UtilCrypto.CheckFileHash ( string  filePath,
string  hashValue,
HashType  hashType 
)
inlinestatic

Chechs the specified type of hash value of a file.

Returns true if the specified hash value matches the hash value of the file, and false otherwise.

Parameters
filePathPath to the file whose hash value is checked.
hashValueSupposed hash value whose correctness is checked.
hashTypeType of the hash value that is checked.
Returns
True if the specified hash hashValue actually matches the hash value of the type hashType of the verified file filePath , or false otherwise.

Referenced by IG.Script.ScriptAppBase.CryptoFunctionCheckSum().

static HashType IG.Crypto.UtilCrypto.CheckFileHashSupportedTypes ( string  filePath,
string  hashValue 
)
inlinestatic

Chechs all supported types of hash value of a file.

Returns the hash type if the hash value matches the hash value of that type of the specified file, or HashType.None if the specified hash value doesn't match the hash value of any supported type of the specified file.

Parameters
filePathPath to the file whose hash value is checked.
hashValueSupposed hash value whose match with the specified file is checked.
Returns
Type of the hash value that matches the specified hash value of the specified file, or HashType.None if the specified hash value doesn't match the hash value of any supported type of the specified file.

Referenced by IG.Forms.HashGeneratorControl.VerifyHash().

static bool IG.Crypto.UtilCrypto.CheckFileHashMd5 ( string  filePath,
string  hashValue 
)
inlinestatic

Checks whether the specified MD5 hash value matches the actual hash value of the specified file.

Returns true if the specified hash value matches the actual hash value of the file, and false otherwise.

Parameters
filePathPath to the file whose hash value is checked.
hashValueSupposed hash value whose validity is checked for the specified file.
Returns
True if the specified file hash value matches the actual value, false otherwise.
static bool IG.Crypto.UtilCrypto.CheckFileHashSha1 ( string  filePath,
string  hashValue 
)
inlinestatic

Checks whether the specified SHA-1 hash value matches the actual hash value of the specified file.

Returns true if the specified hash value matches the actual hash value of the file, and false otherwise.

Parameters
filePathPath to the file whose hash value is checked.
hashValueSupposed hash value whose validity is checked for the specified file.
Returns
True if the specified file hash value matches the actual value, false otherwise.
static bool IG.Crypto.UtilCrypto.CheckFileHashSha256 ( string  filePath,
string  hashValue 
)
inlinestatic

Checks whether the specified SHA-256 hash value matches the actual hash value of the specified file.

Returns true if the specified hash value matches the actual hash value of the file, and false otherwise.

Parameters
filePathPath to the file whose hash value is checked.
hashValueSupposed hash value whose validity is checked for the specified file.
Returns
True if the specified file hash value matches the actual value, false otherwise.
static bool IG.Crypto.UtilCrypto.CheckFileHashSha512 ( string  filePath,
string  hashValue 
)
inlinestatic

Checks whether the specified SHA-512 hash value matches the actual hash value of the specified file.

Returns true if the specified hash value matches the actual hash value of the file, and false otherwise.

Parameters
filePathPath to the file whose hash value is checked.
hashValueSupposed hash value whose validity is checked for the specified file.
Returns
True if the specified file hash value matches the actual value, false otherwise.

The documentation for this class was generated from the following file: