| IGLib 1.5 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
Classes | Static Public Member Functions | List of all members
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 | ) |
| inline static

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

-1 is returned if the length is not known.

Parameters

  hashType | Type of the hashing algorithm.

static int IG.Crypto.UtilCrypto.GetHashLengthHex | ( | HashType | hashType | ) |
| inline static

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

-1 is returned if the length is not known.

Parameters

  hashType | Type of the hashing algorithm.

static HashAlgorithm IG.Crypto.UtilCrypto.CreateHashAlgorithm | ( | HashType | hashType | ) |
| inline static

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

  hashType | Specification of the hash algorthm type.

static HashType IG.Crypto.UtilCrypto.GetHashType | ( | string | typeString | ) |
| inline static

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

static string IG.Crypto.UtilCrypto.GetHashType | ( | HashType | hashType | ) |
| inline static

Returns standard string representation of the specified hash type.

Does the same as HashTypeToString.

Parameters

  hashType | Hash type whose string representation is returned.

static string IG.Crypto.UtilCrypto.HashTypeToString | ( | HashType | hashType | ) |
| inline static

Returns standard string representation of the specified hash type.

Parameters

  hashType | Hash type whose string representation is returned.

static void IG.Crypto.UtilCrypto.ParseHashFile | ( | string | filePath,
|  | ref List< string[]> | hashList
| ) |  |
| inline static

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

  filePath | Path to the file that is parsed.
  hashList | List 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
| ) |  |
| inline static

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

  str | String that is parsed.
  hashList | List 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
| ) |  |
| inline static

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

  stringToHash | String whose hash string is calculated.
  hashType | Specifies the type of the hashing algorithm to be used.

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

static string IG.Crypto.UtilCrypto.GetStringHashMd5 | ( | string | stringToHash | ) |
| inline static

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

Parameters

  stringToHash | String whose cryptographic hash is calculated.

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

static string IG.Crypto.UtilCrypto.GetStringHashSha1 | ( | string | stringToHash | ) |
| inline static

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

Parameters

  stringToHash | String whose cryptographic hash is calculated.

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

static string IG.Crypto.UtilCrypto.GetStringHashSha256 | ( | string | stringToHash | ) |
| inline static

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

Parameters

  stringToHash | String whose cryptographic hash is calculated.

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

static string IG.Crypto.UtilCrypto.GetStringHashSha512 | ( | string | stringToHash | ) |
| inline static

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

Parameters

  stringToHash | String whose cryptographic hash is calculated.

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

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

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

  stringToCheck | String whose hash value is checked.
  hashValue | Supposed hash value whose correctness is checked.
  hashType | Type 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
| ) |  |
| inline static

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

  stringToCheck | String whose hash value is checked.
  hashValue | Supposed 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
| ) |  |
| inline static

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

  stringToCheck | String whose hash value is checked.
  hashValue | Supposed 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
| ) |  |
| inline static

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

  stringToCheck | String whose hash value is checked.
  hashValue | Supposed 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
| ) |  |
| inline static

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

  stringToCheck | String whose hash value is checked.
  hashValue | Supposed 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
| ) |  |
| inline static

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

  stringToCheck | String whose hash value is checked.
  hashValue | Supposed 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
| ) |  |
| inline static

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

Parameters

  filePath | Path to the file whose contents' cryptographic hash is calculated.
  hashType | Specifies the type of the hashing algorithm to be used.

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

static string IG.Crypto.UtilCrypto.GetFileHashMd5 | ( | string | filePath | ) |
| inline static

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

Parameters

  filePath | Path 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 | ) |
| inline static

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

Parameters

  filePath | Path 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 | ) |
| inline static

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

Parameters

  filePath | Path 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 | ) |
| inline static

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

Parameters

  filePath | Path 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
| ) |  |
| inline static

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

Parameters

  stream | Stream whose contents' cryptographic hash is calculated.

static string IG.Crypto.UtilCrypto.GetHashMd5 | ( | Stream | stream | ) |
| inline static

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

Parameters

  stream | Stream whose contents' cryptographic hash is calculated.

static string IG.Crypto.UtilCrypto.GetHashSha1 | ( | Stream | stream | ) |
| inline static

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

Parameters

  stream | Stream whose contents' cryptographic hash is calculated.

static string IG.Crypto.UtilCrypto.GetHashSha256 | ( | Stream | stream | ) |
| inline static

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

Parameters

  stream | Stream whose contents' cryptographic hash is calculated.

static string IG.Crypto.UtilCrypto.GetHashSha512 | ( | Stream | stream | ) |
| inline static

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

Parameters

  stream | Stream whose contents' cryptographic hash is calculated.

static bool IG.Crypto.UtilCrypto.CheckFileHash | ( | string | filePath,
|  | string | hashValue,
|  | HashType | hashType
| ) |  |
| inline static

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

  filePath | Path to the file whose hash value is checked.
  hashValue | Supposed hash value whose correctness is checked.
  hashType | Type 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
| ) |  |
| inline static

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

  filePath | Path to the file whose hash value is checked.
  hashValue | Supposed 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
| ) |  |
| inline static

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

  filePath | Path to the file whose hash value is checked.
  hashValue | Supposed 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
| ) |  |
| inline static

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

  filePath | Path to the file whose hash value is checked.
  hashValue | Supposed 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
| ) |  |
| inline static

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

  filePath | Path to the file whose hash value is checked.
  hashValue | Supposed 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
| ) |  |
| inline static

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

  filePath | Path to the file whose hash value is checked.
  hashValue | Supposed 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:

- igbase/utilities/UtilCrypto.cs