IGLib
1.6.0
The IGLib base library for development of numerical, technical and business applications.
|
Basic Cryptographic utilities. More...
Static Public Member Functions | |
static PasswordAlgorithmType[] | GetPasswordAlgorithmTypes () |
Returns all password algorithm types contained in the enumeration PasswordAlgorithmType More... | |
static PasswordAlgorithmType | GetPasswordAlgorithmType (string typeString) |
Returns a PasswordAlgorithmType value corresponding to the specified string representation. More... | |
static PasswordAlgorithmType | GetPasswordAlgorithmType (PasswordAlgorithmBase algorithmObject) |
Returns the password generation algorithm type, i.e. an enumeration of type PasswordAlgorithmType, for the specified password generation algorithm object. More... | |
static string | PasswordAlgorithmTypeToString (PasswordAlgorithmType passwordAlgorithmType) |
Returns standard string representation of the specified password generation algoithm. More... | |
static IG.Crypto.PasswordAlgorithmBase | GetPasswordAlgorithm (PasswordAlgorithmType algorithmType) |
Returns the appropriate password generation algorithm according to the specified algorithm type, or null if the type is not recognized or the method is not implemented for that type. More... | |
static bool | IsCorrectPasswordAlgorithm (DeriveBytes algorithm, PasswordAlgorithmType algorithmType) |
Returns true if the specified password generation algorithm corresponds the type specification, false otherwise. More... | |
static string | CreateRandomPassword (int PasswordLength, string allowedChars=null) |
Creates and returns a random password consisting of only allowed characters from the specified string. More... | |
static void | GetRandomBytes (byte[] byteArray) |
Fills the specified byte array with a cryptographically strong sequence of random bytes. More... | |
static void | GetRandomBytes (ref byte[] byteArray, int numBytes) |
Fills the specified byte array with a specified number of cryptographically strong random bytes. More... | |
static byte[] | GetRandomBytes (int numBytes) |
Creates and returns an array of cryptographically strong random bytes of the specified size. More... | |
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 HashType[] | GetHashTypes () |
Returns all hashing algorithm types contained in the enumeration HashType More... | |
static HashType | GetHashType (string typeString) |
Returns a HashType value corresponding to the specified string representation. More... | |
static HashType | GetHashType (HashAlgorithm algorithmObject) |
Returns the hashing algorithm type, i.e. an enumeration of type HashType, for the specified hashing algorithm object. More... | |
static string | HashTypeToString (HashType hashType) |
Returns standard string representation of the specified hash type. More... | |
static HashAlgorithm | GetHashAlgorithm (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 bool | IsCorrectHashAlgorithm (HashAlgorithm algorithm, HashType algorithmType) |
Returns true if the specified cryptographic hash algorithm corresponds the type specification, false otherwise. 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, inputFilePath} 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, inputFilePath} to the specified list. More... | |
static byte[] | GetHashBytes (byte[] bytesToHash, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hash (in form of byte array) of the specified kind of the specified byte array. More... | |
static string | GetHashHex (byte[] bytesToHash, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hash string of the specified kind of the specified byte array. More... | |
static string | GetHashMd5Hex (byte[] bytesToHash) |
Computes and returns the MD5 hash string of the specified array of bytes. More... | |
static string | GetHashSha1Hex (byte[] bytesToHash) |
Computes and returns the SHA1 hash string of the specified array of bytes. More... | |
static string | GetHashSha256Hex (byte[] bytesToHash) |
Computes and returns the SHA256 hash string of the specified array of bytes. More... | |
static string | GetHashSha512Hex (byte[] bytesToHash) |
Computes and returns the SHA512 hash string of the specified array of bytes. More... | |
static bool | CheckHashHex (byte[] bytesToCheck, string hashValue, HashType hashAlgorithmType) |
Chechs the specified type of hash value of a byte array. More... | |
static HashType | CheckHashSupportedTypesHex (byte[] bytesToCheck, string hashValue) |
Chechs all supported types of hash value of a string. More... | |
static byte[] | GetStringHashBytes (string stringToHash, HashType hashType=HashType.Default, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hash string of the specified kind of the specified string. More... | |
static string | GetStringHashHex (string stringToHash, HashType hashType=HashType.Default, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hash string of the specified kind of the specified string. More... | |
static string | GetStringHashMd5Hex (string stringToHash) |
Computes and returns the MD5 hash string of the specified string. More... | |
static string | GetStringHashSha1Hex (string stringToHash) |
Computes and returns the SHA1 hash string of the specified string. More... | |
static string | GetStringHashSha256Hex (string stringToHash) |
Computes and returns the SHA256 hash string of the specified string. More... | |
static string | GetStringHashSha512Hex (string stringToHash) |
Computes and returns the SHA512 hash string of the specified string. More... | |
static byte[] | GetStringSaltedHashBytes (string stringToHash, HashType hashType, string salt, int numIterations=0, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the salted hash (in form of byte array) of the specified kind of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHash (string stringToHash, HashType hashType, string salt, int numIterations=0, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the salted hash of the specified kind of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHashMd5Hex (string stringToHash, string salt, int numIterations=0) |
Computes and returns the MD5 salted hash of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHashSha1Hex (string stringToHash, string salt, int numIterations=0) |
Computes and returns the SHA1 salted hash of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHashSha256Hex (string stringToHash, string salt, int numIterations=0) |
Computes and returns the SHA-256 salted hash of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static string | GetStringSaltedHashSha512Hex (string stringToHash, string salt, int numIterations=0) |
Computes and returns the SHA-512 salted hash of the specified string, with the specified number of repetitions of the salted hashing algoriithm. More... | |
static bool | CheckStringHashHex (string stringToCheck, string hashValue, HashType hashAlgorithmType) |
Chechs the specified type of hash value of a string. More... | |
static HashType | CheckStringHashSupportedTypesHex (string stringToCheck, string hashValue) |
Chechs all supported types of hash value of a string. More... | |
static bool | CheckStringHashMd5Hex (string stringToCheck, string hashValue) |
Checks whether the specified MD5 hash value matches the actual hash value of the specified string. More... | |
static bool | CheckStringHashSha1Hex (string stringToCheck, string hashValue) |
Checks whether the specified SHA-1 hash value matches the actual hash value of the specified string. More... | |
static bool | CheckStringHashSha256Hex (string stringToCheck, string hashValue) |
Checks whether the specified SHA-256 hash value matches the actual hash value of the specified string. More... | |
static bool | CheckStringHashSha512Hex (string stringToCheck, string hashValue) |
Checks whether the specified SHA-512 hash value matches the actual hash value of the specified string. More... | |
static byte[] | GetFileHashBytes (string filePath, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hash (in form of byte array) of specified type of the specified stream. More... | |
static string | GetFileHashHex (string filePath, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hash string of specified type of the specified stream. More... | |
static string | GetFileHashMd5Hex (string filePath, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the MD5 hash string of the specified stream. More... | |
static string | GetFileHashSha1Hex (string filePath, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA1 hash string of the specified stream. More... | |
static string | GetFileHashSha256Hex (string filePath, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA256 hash string of the specified stream. More... | |
static string | GetFileHashSha512Hex (string filePath, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA512 hash string of the specified stream. More... | |
static byte[] | GetHashBytes (Stream stream, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hash (in form of byte array) of specified type of the specified stream. More... | |
static string | GetHashHex (Stream stream, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the hexadecimal hash string of specified type of the specified stream. More... | |
static string | GetHashMd5Hex (Stream stream, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the MD5 hash string of the specified stream. More... | |
static string | GetHashSha1Hex (Stream stream, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA1 hash string of the specified stream. More... | |
static string | GetHashSha256Hex (Stream stream, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA256 hash string of the specified stream. More... | |
static string | GetHashSha512Hex (Stream stream, HashAlgorithm cryptoAlgorithm=null) |
Computes and returns the SHA512 hash string of the specified stream. More... | |
static bool | CheckFileHashHex (string filePath, string hashValue, HashType hashType, HashAlgorithm cryptoAlgorithm=null) |
Chechs the specified type of hash value of a file. More... | |
static HashType | CheckFileHashSupportedTypesHex (string filePath, string hashValue) |
Chechs all supported types of hash value of a file. More... | |
static bool | CheckFileHashMd5Hex (string filePath, string hashValue) |
Checks whether the specified MD5 hash value matches the actual hash value of the specified file. More... | |
static bool | CheckFileHashSha1Hex (string filePath, string hashValue) |
Checks whether the specified SHA-1 hash value matches the actual hash value of the specified file. More... | |
static bool | CheckFileHashSha256Hex (string filePath, string hashValue) |
Checks whether the specified SHA-256 hash value matches the actual hash value of the specified file. More... | |
static bool | CheckFileHashSha512Hex (string filePath, string hashValue) |
Checks whether the specified SHA-512 hash value matches the actual hash value of the specified file. More... | |
static SymmetricAlgorithmType[] | GetSymmetricAlgorithmTypes () |
Returns all symmetric encryption algorithm types contained in the enumeration SymmetricAlgorithmType More... | |
static SymmetricAlgorithmType | GetSymmetricAlgorithmType (string typeString) |
Returns the SymmetricAlgorithmType value corresponding to the specified string. More... | |
static SymmetricAlgorithmType | GetSymmetricAlgorithmType (SymmetricAlgorithm algorithmObject) |
Returns the symmetric encryption algorithm type, i.e. an enumeration of type SymmetricAlgorithmType, for the specified symmetric encryption algorithm object. More... | |
static string | SymmetricAlgorithmTypeToString (SymmetricAlgorithmType algorithmType) |
Returns standard string representation of the specified symmetric encryption algorithm type. More... | |
static SymmetricAlgorithm | GetSymmetricEncryptionAlgorithm (SymmetricAlgorithmType algorithmType) |
Returns the appropriate symmetric encryption 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 bool | IsCorrectSymmetricEncryptionAlgorithm (SymmetricAlgorithm algorithm, SymmetricAlgorithmType algorithmType) |
Returns true if the specified symmetric encryption algorithm corresponds the type specification, false otherwise. More... | |
static byte[] | PadToAlgorithmBlocksizeCyclic (byte[] byteArray, int blockSize, bool truncateIfLarger=false) |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified initialization array is returned, otherwise the modified array that fits the required block size is returned (i.e. has integer number of blocks). More... | |
static byte[] | PadToAlgorithmBlocksizeZero (byte[] byteArray, int blockSize, bool truncateIfLarger=false) |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified initialization array is returned, otherwise the modified array that fits the required block size is returned (i.e. has integer number of blocks). More... | |
static byte[] | PadToSymmetricAlgorithmBlocksizeCyclic (byte[] byteArray, SymmetricAlgorithm algorithm, bool truncateIfLarger=false) |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified array is returned, otherwise the modified array that fits the required block size is returned. The array size must be mltiple of the block size. More... | |
static byte[] | PadToSymmetricAlgorithmBlocksizeZero (byte[] byteArray, SymmetricAlgorithm algorithm, bool truncateIfLarger=false) |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified array is returned, otherwise the modified array that fits the required block size is returned. The array size must be mltiple of the block size. More... | |
static byte[] | GetValidSymmetricAlgorithmKey (byte[] key, SymmetricAlgorithm algorithm) |
For the specified symmetric encryption algorithm, this function takes the specified key and checks if the key is of valid size. If yes then the unmodified key is returned, otherwise the modified key that fits the required size is returned. More... | |
static byte[] | GetValidSymmetricAlgorithmIV (byte[] IV, SymmetricAlgorithm algorithm) |
For the specified symmetric encryption algorithm, this function takes the specified initialization vector and checks if the vector is of valid size. If yes then the unmodified IV is returned, otherwise the modified IV that fits the required size is returned. More... | |
static int | GetLargestSymmetricAlgorithmKeySize (SymmetricAlgorithm algorithm) |
Returns the largest possible key siye, in bits, for the spcified symmetric encryption algorithm. More... | |
static int | GetLargestSymmetricAlgorithmBlockSize (SymmetricAlgorithm algorithm) |
Returns the largest possible block siye, in bits, for the spcified symmetric encryption algorithm. More... | |
static void | PrepareSymmetricAllgorithmBasic (byte[] passwordBytes, byte[] passwordSalt, ref byte[] key, ref byte[] IV, SymmetricAlgorithmType algorithmType, ref SymmetricAlgorithm algorithm, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Prepares the symmetric algorithm, initialization vector, and key before encryption or decryption takes place. More... | |
static byte[] | EncryptBasic (byte[] data, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified byte array by a symmetric encryption algorithm and returns encrypted bytes. More... | |
static byte[] | DecryptBasic (byte[] data, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the specified byte array by a symmetric algorithm and returns decrypted data. More... | |
static string | EncryptStringBasic (string stringToEncrypt, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified string, using the specified symmetric algorithm, key, and initialization vector, and returns the ToBase64 string representation of the encrypted bytes. More... | |
static string | DecryptStringBasic (string cipherText, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector. More... | |
static void | EncryptFileBasic (string inputFilePath, string outputFilePath, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, int bufferSize=ConstCrypto.FileBufferSize, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the data from the specified input file by a symmetric encryption algorithm and writes encrypted data to the specified output file. More... | |
static void | DecryptFileBasic (string inputFilePath, string outputFilePath, byte[] passwordBytes, byte[] passwordSalt, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, int bufferSize=ConstCrypto.FileBufferSize, PasswordAlgorithmType pwdType=PasswordAlgorithmType.Default, int pwdNumIterations=1000, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the data from the specified input file by a symmetric encryption algorithm and writes decrypted data to the specified output file. More... | |
static void | PrepareSymmetricAllgorithmPlain (ref byte[] key, ref byte[] IV, SymmetricAlgorithmType algorithmType, ref SymmetricAlgorithm algorithm, bool useLargestKey=false, bool useLargestBlock=false) |
Prepares the symmetric algorithm, initialization vector, and key before encryption or decryption takes place. More... | |
static void | EncryptPlain (byte[] data, Stream outputStream, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified byte array by a symmetric encryption algorithm and writes encrypted data to the specified output stream that must be open for writing. More... | |
static void | DecryptPlain (byte[] data, Stream outputStream, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the specified byte array by a symmetric algorithm and writes decrypted data to the specified output stream. More... | |
static byte[] | EncryptPlain (byte[] data, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified byte array by a symmetric encryption algorithm and returns encrypted bytes. More... | |
static byte[] | DecryptPlain (byte[] data, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the specified byte array by a symmetric algorithm and returns decrypted data. More... | |
static string | EncryptStringPlain (string stringToEncrypt, byte[] key, byte[] initializationVector, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified string, using the specified symmetric algorithm, key, and initialization vector, and returns the Base64 string representation of the encrypted bytes. More... | |
static string | DecryptStringPlain (string cipherText, byte[] key, byte[] initializationVector, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, bool useLargestKey=false, bool useLargestBlock=false) |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector. More... | |
static byte[] | EncryptStringToBytesPlain (string stringToEncrypt, byte[] key, byte[] initializationVector, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the specified string to a byte array, using the specified symmetric algorithm, key, and initialization vector. More... | |
static string | DecryptStringFromBytesPlain (byte[] cipherText, byte[] key, byte[] initializationVector, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.Default, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, bool useLargestKey=false, bool useLargestBlock=false) |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector. More... | |
static void | EncryptPlain (Stream inputStream, Stream outputStream, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, int bufferSize=ConstCrypto.FileBufferSize, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the data from the specified input stream by a symmetric encryption algorithm and writes encrypted data to the specified output stream. More... | |
static void | DecryptPlain (Stream inputStream, Stream outputStream, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, int bufferSize=ConstCrypto.FileBufferSize, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the data from the specified input stream by a symmetric encryption algorithm and writes decrypted data to the specified output stream. More... | |
static void | EncryptFilePlain (string inputFilePath, string outputFilePath, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, byte[] saltBytes=null, int bufferSize=ConstCrypto.FileBufferSize, bool useLargestKey=false, bool useLargestBlock=false) |
Encrypts the data from the specified input file by a symmetric encryption algorithm and writes encrypted data to the specified output file. More... | |
static void | DecryptFilePlain (string inputFilePath, string outputFilePath, byte[] key, byte[] IV, SymmetricAlgorithmType algorithmType=SymmetricAlgorithmType.None, SymmetricAlgorithm algorithm=null, int numSaltBytes=0, int bufferSize=ConstCrypto.FileBufferSize, bool useLargestKey=false, bool useLargestBlock=false) |
Decrypts the data from the specified input file by a symmetric encryption algorithm and writes decrypted data to the specified output file. More... | |
static AsymmetricAlgorithmType[] | GetAsymmetricAlgorithmTypes () |
Returns all asymmetric encryption algorithm types contained in the enumeration AsymmetricAlgorithmType More... | |
static AsymmetricAlgorithmType | GetAsymmetricAlgorithmType (string typeString) |
Returns the AsymmetricAlgorithmType value corresponding to the specified string. More... | |
static AsymmetricAlgorithmType | GetAsymmetricAlgorithmType (AsymmetricAlgorithm algorithmObject) |
Returns the asymmetric encryption algorithm type, i.e. an enumeration of type SymmetricAlgorithmType, for the specified asymmetric encryption algorithm object. More... | |
static string | AsymmetricAlgorithmTypeToString (AsymmetricAlgorithmType algorithmType) |
Returns standard string representation of the specified asymmetric encryption algorithm type. More... | |
static AsymmetricAlgorithm | GetAsymmetricEncryptionAlgorithm (AsymmetricAlgorithmType algorithmType) |
Returns the appropriate asymmetric 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 bool | IsCorrectAsymmetricEncryptionAlgorithm (AsymmetricAlgorithm algorithm, AsymmetricAlgorithmType algorithmType) |
Returns true if the specified asymmetric encryption algorithm corresponds the type specification, false otherwise. More... | |
static int | GetLargestAsymmetricAlgorithmKeySize (AsymmetricAlgorithm algorithm) |
Returns the largest possible key size, in bits, for the spcified symmetric encryption algorithm. More... | |
static byte[] | GetValidAsymmetricAlgorithmKey (byte[] key, AsymmetricAlgorithm algorithm, bool useLargestKey=false) |
For the specified asymmetric encryption algorithm, this function takes the specified key and checks if the key is of valid size. If yes then the unmodified key is returned, otherwise the modified key that fits the required size is returned. More... | |
static string | IgGetSaltSuffix (int whichSalt) |
Returns the specified standard IGLib salt string. More... | |
static int | IgGetNumSaltSuffices () |
Returns the number of standard IGLib salt strings. More... | |
Properties | |
static int | OutputLevel [get] |
Output level for static methods of the current utility class. More... | |
static object | LockStatic [get] |
Locking object for static methods and properties of this class. More... | |
static Encoding | StringEncoding [get] |
Gets the character encoding that is used for calculating hashes of strings. More... | |
static RNGCryptoServiceProvider | Rng [get] |
Object used to generate random bytes. More... | |
Static Private Member Functions | |
static PasswordAlgorithmBase | GetPasswordAlgorithmNoneSingleton () |
Returns password algorithm that does not change the password provided as initialization parameters. More... | |
static int | SetLargestSymmetricAlgorithmKeySize (SymmetricAlgorithm algorithm) |
On the specified symmetric encryption algorythm, sets the largest possible key size, in bits, for the spcified symmetric encryption algorithm. More... | |
static int | SetLargestSymmetricAlgorithmBlockSize (SymmetricAlgorithm algorithm) |
On the specified symmetric encryption algorithm, sets the largest possible block size, in bits, for the spcified symmetric encryption algorithm. More... | |
static int | SetLargestAsymmetricAlgorithmKeySize (AsymmetricAlgorithm algorithm) |
On the specified asymmetric encryption algorithm, sets the largest possible key size, in bits, for the corresponding asymmetric encryption algorithm. More... | |
Static Private Attributes | |
static int | _outputLevel = 1 |
static object | _lockStatic = null |
static PasswordAlgorithmType[] | _passwordAlgorithmTypes = null |
static PasswordAlgorithmBase | _passwordAlgorithmNone = null |
static RNGCryptoServiceProvider | _rng = null |
static HashType[] | _hashTypes = null |
static SymmetricAlgorithmType[] | _symmetricTypes = null |
static AsymmetricAlgorithmType[] | _asymmetricTypes = null |
static string[] | _igLibLongSaltSuffices |
An array of standard IGLib salt suffices. More... | |
Basic Cryptographic utilities.
Warnings:
- Functions of this class must be fixed (may not change over time) in order not to break any security instruments.
- Functions can only be renamd (always by refactoring tools that change all calls to functions).
- For IGLib functions (IGLib specific supplements of standards), these should only be used through standard shell applications. In such a way security tools can not be broken, as shell functions are more guaranteed to behave constantly over time.
See also:
- Cryptographic hash function: http://en.wikipedia.org/wiki/Cryptographic_hash_function
- Password verification: http://en.wikipedia.org/wiki/Cryptographic_hash_function#Password_verification
- Storing passwords: http://www.aspheute.com/english/20040105.asp
- How to encrypt user passwords: http://www.jasypt.org/howtoencryptuserpasswords.html
- Salt: https://en.wikipedia.org/wiki/Salt_(cryptography)
- Key stretching: http://en.wikipedia.org/wiki/Key_stretching
$A Igor Apr10 Jun15;
|
inlinestatic |
Returns all password algorithm types contained in the enumeration PasswordAlgorithmType
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns a PasswordAlgorithmType value corresponding to the specified string representation.
typeString | String that represents the PasswordAlgorithmType value. |
Referenced by IG.Crypto.CryptoManager.AppKeyGenerationAll(), IG.Script.ScriptAppBase.CryptoFunctionEncrypt_OLD_TO_DELETE(), IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.CryptoManager.ParseCommandlineParameters().
|
inlinestatic |
Returns the password generation algorithm type, i.e. an enumeration of type PasswordAlgorithmType, for the specified password generation algorithm object.
algorithmObject | Password generaton algorithm object for which type enumeration is returned. |
|
inlinestatic |
Returns standard string representation of the specified password generation algoithm.
Password algorithm type whose string representation is returned.
Referenced by IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmBasic().
|
inlinestaticprivate |
Returns password algorithm that does not change the password provided as initialization parameters.
The same object is returned by each call.
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns the appropriate password generation algorithm according to the specified algorithm type, or null if the type is not recognized or the method is not implemented for that type.
algorithmType | Specification of the password generaion algorithm type. |
Referenced by IG.Crypto.CryptoManager.AppKeyGenerationAll(), IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmBasic().
|
inlinestatic |
Returns true if the specified password generation algorithm corresponds the type specification, false otherwise.
If the specified algorithm is null or the specified type is unknown then false is returned.
algorithmType | Specification of the password derivation nalgorithm type. |
algorithm | Algorithm that is checked for type correctness. |
|
inlinestatic |
Creates and returns a random password consisting of only allowed characters from the specified string.
Cryptographically secure random numbers are used to select characters for the password from the array of allowed characters.
PasswordLength | Length of the generated password. |
allowedChars | String containing allowed characters of the password. |
By default (if parameter is a null or empty string), these are digits and lower- and upper- case English letters.
|
inlinestatic |
Fills the specified byte array with a cryptographically strong sequence of random bytes.
byteArray | Byte array that is filled with random bytes. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.CryptoManager.ResolvePasswordParameters().
|
inlinestatic |
Fills the specified byte array with a specified number of cryptographically strong random bytes.
Byte array is created anew if its size does not equal the specified number of bytes.
byteArray | Byte array that is filled with random bytes. Reallocated if necessary. |
numBytes | Number of bytes to be filled into the array. |
|
inlinestatic |
Creates and returns an array of cryptographically strong random bytes of the specified size.
numBytes | Number of bytes to be filled into the array. |
|
inlinestatic |
Returns length of the hash value, in bytes, for the specified hash algorithm.
-1 is returned if the length is not known.
HashAlgorithmType | Type of the hashing algorithm. |
|
inlinestatic |
Returns length of the HEXADECIMAL hash string for the specified hash algorithm.
-1 is returned if the length is not known.
HashAlgorithmType | Type of the hashing algorithm. |
|
inlinestatic |
Returns all hashing algorithm types contained in the enumeration HashType
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns a HashType value corresponding to the specified string representation.
typeString | String that represents the hash type. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER(), IG.Script.ScriptAppBase.CryptoFunctionEncrypt_OLD_TO_DELETE(), and IG.Crypto.CryptoManager.ParseCommandlineParameters().
|
inlinestatic |
Returns the hashing algorithm type, i.e. an enumeration of type HashType, for the specified hashing algorithm object.
algorithmObject | Hashing algorithm object for which type enumeration is returned. |
|
inlinestatic |
Returns standard string representation of the specified hash type.
HashAlgorithmType | Hash type whose string representation is returned. |
|
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.
HashAlgorithmType | Specification of the hash algorithm type. |
|
inlinestatic |
Returns true if the specified cryptographic hash algorithm corresponds the type specification, false otherwise.
If the specified algorithm is null or the specified type is unknown then false is returned.
algorithmType | Specification of the cryptographic hash algorithm type. |
algorithm | Algorithm that is checked for type correctness. |
|
inlinestatic |
Parses the file containing hash values of one or more files, and adds the parsed pairs {hash, inputFilePath} 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.
inputFilePath | Path to the file that is parsed. |
hashList | List to which which parsed pairs {hash, inputFilePath} 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.Crypto.CryptoManager.AppCheckSum(), IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER(), and IG.Script.ScriptAppBase.CryptoFunctionEncrypt_OLD_TO_DELETE().
|
inlinestatic |
Parses the string containing hash values of one or more files, and adds the parsed pairs {hash, inputFilePath} 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.
str | String that is parsed. |
hashList | List to which which parsed pairs {hash, inputFilePath} are added in form of arrays of 2 strings. |
Example contents of the string:
595f44fec1e92a71d3e9e77456ba80d1 filetohashA.txt
71f920fa275127a7b60fa4d4d41432a3 filetohashB.txt
43c191bf6d6c3f263a8cd0efd4a058ab filetohashC.txt
/remarks>
|
inlinestatic |
Computes and returns the hash (in form of byte array) of the specified kind of the specified byte array.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
bytesToHash | Byte array whose hash string is calculated. |
HashAlgorithmType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the hash string of the specified kind of the specified byte array.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
bytesToHash | Byte array whose hash string is calculated. |
HashAlgorithmType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
References IG.Lib.Util.ToHexString().
Referenced by IG.Crypto.CryptoManager.AppCheckSum().
|
inlinestatic |
Computes and returns the MD5 hash string of the specified array of bytes.
bytesToHash | Byte array whose hash string is calculated. |
|
inlinestatic |
Computes and returns the SHA1 hash string of the specified array of bytes.
bytesToHash | Byte array whose hash string is calculated. |
|
inlinestatic |
Computes and returns the SHA256 hash string of the specified array of bytes.
bytesToHash | Byte array whose hash string is calculated. |
|
inlinestatic |
Computes and returns the SHA512 hash string of the specified array of bytes.
bytesToHash | Byte array whose hash string is calculated. |
|
inlinestatic |
Chechs the specified type of hash value of a byte array.
Returns true if the hash value matches the hash value of the byte array, and false otherwise.
bytesToCheck | String whose hash value is checked. |
HashValue | Supposed hash value whose correctness is checked. |
HashAlgorithmType | Type of the hash value that is checked. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Crypto.CryptoManager.AppCheckSum().
|
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.
bytesToCheck | String whose hash value is checked. |
HashValue | Supposed hash value whose match with the specified string is checked. |
References IG.Lib.Util.AreHexStringsEqual().
|
inlinestatic |
Computes and returns the hash string of the specified kind of the specified string.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
stringToHash | String whose hash string is calculated. |
HashAlgorithmType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the hash string of the specified kind of the specified string.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
stringToHash | String whose hash string is calculated. |
HashAlgorithmType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
References IG.Lib.Util.ToHexString().
Referenced by IG.Crypto.CryptoManager.AppCheckSum(), IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER(), and IG.Script.ScriptAppBase.CryptoFunctionEncrypt_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the MD5 hash string of the specified string.
stringToHash | String whose cryptographic hash is calculated. |
Referenced by IG.Forms.HashGeneratorControl.CalculateHashes().
|
inlinestatic |
Computes and returns the SHA1 hash string of the specified string.
stringToHash | String whose cryptographic hash is calculated. |
Referenced by IG.Forms.HashGeneratorControl.CalculateHashes().
|
inlinestatic |
Computes and returns the SHA256 hash string of the specified string.
stringToHash | String whose cryptographic hash is calculated. |
Referenced by IG.Forms.HashGeneratorControl.CalculateHashes().
|
inlinestatic |
Computes and returns the SHA512 hash string of the specified string.
stringToHash | String whose cryptographic hash is calculated. |
Referenced by IG.Forms.HashGeneratorControl.CalculateHashes().
|
inlinestatic |
Computes and returns the salted hash (in form of byte array) of the specified kind of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
stringToHash | String whose salted hash is to be computed. |
HashAlgorithmType | Type of hashing algorithm used. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the salted hash of the specified kind of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
stringToHash | String whose salted hash is to be computed. |
HashAlgorithmType | Type of hashing algorithm used. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
References IG.Lib.Util.ToHexString().
|
inlinestatic |
Computes and returns the MD5 salted hash of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
stringToHash | String whose salted hash is to be computed. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
|
inlinestatic |
Computes and returns the SHA1 salted hash of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
stringToHash | String whose salted hash is to be computed. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
|
inlinestatic |
Computes and returns the SHA-256 salted hash of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
stringToHash | String whose salted hash is to be computed. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
|
inlinestatic |
Computes and returns the SHA-512 salted hash of the specified string, with the specified number of repetitions of the salted hashing algoriithm.
Exception (InvalidOperationException) is thrown if the specified hash type is not known or implemented.
stringToHash | String whose salted hash is to be computed. |
salt | Salt string. |
numIterations | Optional number of iterations. If hreater than 0 then hashing algorithm is reapplied to the salted result of the previous computation for the specified number of time. |
|
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.
bytesToCheck | String whose hash value is checked. |
HashValue | Supposed hash value whose correctness is checked. |
HashAlgorithmType | Type of the hash value that is checked. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Crypto.CryptoManager.AppCheckSum(), IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER(), and IG.Script.ScriptAppBase.CryptoFunctionEncrypt_OLD_TO_DELETE().
|
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.
bytesToCheck | String whose hash value is checked. |
HashValue | Supposed hash value whose match with the specified string is checked. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Forms.HashGeneratorControl.VerifyHash().
|
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.
bytesToCheck | String whose hash value is checked. |
HashValue | Supposed hash value whose validity is checked for the specified string. |
|
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.
bytesToCheck | String whose hash value is checked. |
HashValue | Supposed hash value whose validity is checked for the specified string. |
|
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.
bytesToCheck | String whose hash value is checked. |
HashValue | Supposed hash value whose validity is checked for the specified string. |
|
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.
bytesToCheck | String whose hash value is checked. |
HashValue | Supposed hash value whose validity is checked for the specified string. |
|
inlinestatic |
Computes and returns the hash (in form of byte array) of specified type of the specified stream.
inputFilePath | Path to the file whose contents' cryptographic hash is calculated. |
HashAlgorithmType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the hash string of specified type of the specified stream.
inputFilePath | Path to the file whose contents' cryptographic hash is calculated. |
HashAlgorithmType | Specifies the type of the hashing algorithm to be used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppCheckSum(), IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER(), and IG.Script.ScriptAppBase.CryptoFunctionEncrypt_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the MD5 hash string of the specified stream.
inputFilePath | Path to the file whose contents' cryptographic hash is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppGetFileHash(), IG.Forms.HashGeneratorControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the SHA1 hash string of the specified stream.
inputFilePath | Path to the file whose contents' cryptographic hash is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppGetFileHash(), IG.Forms.HashGeneratorControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the SHA256 hash string of the specified stream.
inputFilePath | Path to the file whose contents' cryptographic hash is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppGetFileHash(), IG.Forms.HashGeneratorControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the SHA512 hash string of the specified stream.
inputFilePath | Path to the file whose contents' cryptographic hash is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by teh method. Its type must correspond the specified type. |
Referenced by IG.Crypto.CryptoManager.AppGetFileHash(), IG.Forms.HashGeneratorControl.CalculateHashes(), and IG.Script.ScriptAppBase.CryptoFunctionGetFileHash_OLD_TO_DELETE().
|
inlinestatic |
Computes and returns the hash (in form of byte array) of specified type of the specified stream.
stream | Stream whose contents' cryptographic hash is calculated. |
HashAlgorithmType | Type of the hash algorithm used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the hexadecimal hash string of specified type of the specified stream.
stream | Stream whose contents' cryptographic hash is calculated. |
HashAlgorithmType | Type of the hash algorithm used. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
References IG.Lib.Util.ToHexString().
|
inlinestatic |
Computes and returns the MD5 hash string of the specified stream.
stream | Stream whose contents' cryptographic hash is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the SHA1 hash string of the specified stream.
stream | Stream whose contents' cryptographic hash is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the SHA256 hash string of the specified stream.
stream | Stream whose contents' cryptographic hash is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
inlinestatic |
Computes and returns the SHA512 hash string of the specified stream.
stream | Stream whose contents' cryptographic hash is calculated. |
cryptoAlgorithm | Algorithm objedt used to perform the job. If not specified then it is created by the method. Its type must correspond the specified type. |
|
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.
inputFilePath | Path to the file whose hash value is checked. |
HashValue | Supposed hash value whose correctness is checked. |
HashAlgorithmType | Type of the hash value that is checked. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Crypto.CryptoManager.AppCheckSum(), IG.Script.ScriptAppBase.CryptoFunctionCheckSum_OLD_TO_DELETE_LATER(), and IG.Script.ScriptAppBase.CryptoFunctionEncrypt_OLD_TO_DELETE().
|
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.
inputFilePath | Path to the file whose hash value is checked. |
HashValue | Supposed hash value whose match with the specified file is checked. |
References IG.Lib.Util.AreHexStringsEqual().
Referenced by IG.Forms.HashGeneratorControl.VerifyHash().
|
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.
inputFilePath | Path to the file whose hash value is checked. |
HashValue | Supposed hash value whose validity is checked for the specified file. |
|
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.
inputFilePath | Path to the file whose hash value is checked. |
HashValue | Supposed hash value whose validity is checked for the specified file. |
|
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.
inputFilePath | Path to the file whose hash value is checked. |
HashValue | Supposed hash value whose validity is checked for the specified file. |
|
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.
inputFilePath | Path to the file whose hash value is checked. |
HashValue | Supposed hash value whose validity is checked for the specified file. |
|
inlinestatic |
Returns all symmetric encryption algorithm types contained in the enumeration SymmetricAlgorithmType
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns the SymmetricAlgorithmType value corresponding to the specified string.
This function enables selection of algorithms with strings that can have arbitrary capitalization of their letters, and are thus friendly for user insertion.
typeString | String that represents the symmetric encryption algorithm type. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionEncrypt_OLD_TO_DELETE(), and IG.Crypto.CryptoManager.ParseCommandlineParameters().
|
inlinestatic |
Returns the symmetric encryption algorithm type, i.e. an enumeration of type SymmetricAlgorithmType, for the specified symmetric encryption algorithm object.
algorithmObject | Symmetric algorithm object for which type enumeration is returned. |
|
inlinestatic |
Returns standard string representation of the specified symmetric encryption algorithm type.
algorithmType | Symmetric encryption algorithm type whose string representation is returned. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Returns the appropriate symmetric encryption algorithm according to the specified hash type, or null if the type is not recognized or the method is not implemented for that type.
algorithmType | Specification of the symmetric encryption algorithm type. |
|
inlinestatic |
Returns true if the specified symmetric encryption algorithm corresponds the type specification, false otherwise.
If the specified algorithm is null or the specified type is unknown then false is returned.
algorithmType | Specification of the symmetric encryption algorithm type. |
algorithm | Algorithm that is checked for type correctness. |
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified initialization array is returned, otherwise the modified array that fits the required block size is returned (i.e. has integer number of blocks).
Bytes that are missing to the last full block are filled cyclically with the original bytes from teh beginning.
byteArray | Original array provided for the algorithm with specified block size. |
blockSize | Block size of the algorithm for which array is repaired, in bytes. |
Warning: Algorithms specify block size in bits, not in bytes.
truncateIfLarger | If true then the byte array is truncated to the block size if it is larger than it. |
Warning: this can only be done with the key and initialization vector, but not with data!!
An array that is of valid size for the algorithm.
If the original initialization vector size matches the required one, the vector is unmodified.
If the original vector is not a multiple of block size, it is padded by its initial bytes until the desired length.
Referenced by IG.Crypto.PasswordAlgorithmNone.GetBytesInternal().
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified initialization array is returned, otherwise the modified array that fits the required block size is returned (i.e. has integer number of blocks).
Bytes that are missing to the last full block are filled cyclically with the original bytes from teh beginning.
byteArray | Original array provided for the algorithm with specified block size. |
blockSize | Block size of the algorithm for which array is repaired. |
truncateIfLarger | If true then the byte array is truncated to the block size if it is larger than it. |
Warning: this can only be done with the key and initialization vector, but not with data!!
An array that is of valid size for the algorithm.
If the original initialization vector size matches the required one, the vector is unmodified.
If the original vector is not a multiple of block size, it is padded by its initial bytes until the desired length.
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified array is returned, otherwise the modified array that fits the required block size is returned. The array size must be mltiple of the block size.
Bytes that are missing to the last full block are filled cyclically with the original bytes from teh beginning.
byteArray | Original byte array provided for the algorithm. |
algorithm | Symmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the block sizes. |
truncateIfLarger | If true then the byte array is truncated to the block size if it is larger than it. |
Warning: this can only be done with the key and initialization vector, but not with data!!
An array of bytes that is of valid size for the algorithm.
If the original initialization vector size matches the required one, the array is unmodified.
If the original array is not a multiple of block size, it is padded by its initial bytes until the desired length.
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified byte array and checks if the array is of valid size. If yes then the unmodified array is returned, otherwise the modified array that fits the required block size is returned. The array size must be mltiple of the block size.
Bytes that are missing to the last full block are filled cyclically with the original bytes from teh beginning.
byteArray | Original byte array provided for the algorithm. |
algorithm | Symmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the block sizes. |
truncateIfLarger | If true then the byte array is truncated to the block size if it is larger than it. |
Warning: this can only be done with the key and initialization vector, but not with data!!
An array of bytes that is of valid size for the algorithm.
If the original initialization vector size matches the required one, the array is unmodified.
If the original array is not a multiple of block size, it is padded by its initial bytes until the desired length.
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified key and checks if the key is of valid size. If yes then the unmodified key is returned, otherwise the modified key that fits the required size is returned.
key | Original key provided for the algorithm. |
algorithm | Symmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the key sizes. |
A key that is of valid size for the algorithm.
If the original key size matches the required one, the key is unmodified.
If the original key is larger than the required one, the first bytes of the provided key are used in the returned key.
If the provided key is smaller than the erquired key size then bytes in the returned key are cyclically repeated bytes from the original key.
|
inlinestatic |
For the specified symmetric encryption algorithm, this function takes the specified initialization vector and checks if the vector is of valid size. If yes then the unmodified IV is returned, otherwise the modified IV that fits the required size is returned.
IV | Original initialization vector provided for the algorithm. |
algorithm | Symmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the initialization vector sizes (i.e., the block sizes). |
An initialization vector that is of valid size for the algorithm (i.e. is of the same size as block size).
If the original key size matches the required one, the IV is unmodified.
If the original IV is larger than the required one, the first bytes of the provided IV are used in the returned IV.
If the provided key is smaller than the erquired IV size (i.e. block size) then bytes in the returned IV are cyclically repeated bytes from the original IV.
|
inlinestatic |
Returns the largest possible key siye, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible key size is returned. |
|
inlinestaticprivate |
On the specified symmetric encryption algorythm, sets the largest possible key size, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible key size is returned. |
|
inlinestatic |
Returns the largest possible block siye, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible block size is returned. |
|
inlinestaticprivate |
On the specified symmetric encryption algorithm, sets the largest possible block size, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible block size is set. |
|
inlinestatic |
Prepares the symmetric algorithm, initialization vector, and key before encryption or decryption takes place.
Creates the algorithm if necessary, changes algorithm parameters (such as key size) when applicable, and checks and corrects the key and initialization vector, if necessary.
key | Key used. Method checks that the key is of correct size and corrects it when necessary. |
IV | Initialization vector used. Method checks that it is consistent with the algorithm's block size and corrects it if it is not. |
algorithmType | Algorithm type. If the algorithm is not specified then it is created anew according to this parameter. |
algorithm | Algorithm used for encryption. If null it is created. If specified then it is checked that it corresponds to the type specified by algorithmType . |
useLargestKey | If true then algorithm parameters are set (if necessary) in such a way that the largest hey length supported by the algorithm is used. |
useLargestBlock | If true then algorithm parameters are set (if necessary) in such a way that the largest hey length supported by the algorithm is used. |
References IG.Crypto.PasswordAlgorithmBase.GetBytes(), IG.Crypto.UtilCrypto.GetPasswordAlgorithm(), IG.Crypto.PasswordAlgorithmBase.Init(), IG.Crypto.ConstCrypto.MinPasswordLength, IG.Crypto.ConstCrypto.MinPasswordSaltLength, and IG.Crypto.UtilCrypto.PasswordAlgorithmTypeToString().
|
inlinestatic |
Encrypts the specified byte array by a symmetric encryption algorithm and returns encrypted bytes.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be encrypted. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
SaltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.ConstCrypto.MinPasswordSaltLength.
|
inlinestatic |
Decrypts the specified byte array by a symmetric algorithm and returns decrypted data.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be decrypted. |
key | Secret key used to decrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
|
inlinestatic |
Encrypts the specified string, using the specified symmetric algorithm, key, and initialization vector, and returns the ToBase64 string representation of the encrypted bytes.
stringToEncrypt | String that is encrypted. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with <param name="algorithmType", or null. |
SaltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
References IG.Crypto.ConstCrypto.MinPasswordSaltLength.
|
inlinestatic |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector.
cipherText | Base64 string representation of the byte array containing the encrypted original string. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with <param name="algorithmType", or null. |
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
|
inlinestatic |
Encrypts the data from the specified input file by a symmetric encryption algorithm and writes encrypted data to the specified output file.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputFilePath | Path to the input file from which data is encrypted. The file must be exist and be readable. |
deletedFilePath | Path to the output file to which encrypted data is written. The file must be writable and will be overwritten if it already exists. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.ConstCrypto.MinPasswordSaltLength.
|
inlinestatic |
Decrypts the data from the specified input file by a symmetric encryption algorithm and writes decrypted data to the specified output file.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputFilePath | Path to the input file from which data is encrypted. The file must be exist and be readable. |
deletedFilePath | Path to the output file to which encrypted data is written. The file must be writable and will be overwritten if it already exists. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
|
inlinestatic |
Prepares the symmetric algorithm, initialization vector, and key before encryption or decryption takes place.
Creates the algorithm if necessary, changes algorithm parameters (such as key size) when applicable, and checks and corrects the key and initialization vector, if necessary.
key | Key used. Method checks that the key is of correct size and corrects it when necessary. |
IV | Initialization vector used. Method checks that it is consistent with the algorithm's block size and corrects it if it is not. |
algorithmType | Algorithm type. If the algorithm is not specified then it is created anew according to this parameter. |
algorithm | Algorithm used for encryption. If null it is created. If specified then it is checked that it corresponds to the type specified by algorithmType . |
useLargestKey | If true then algorithm parameters are set (if necessary) in such a way that the largest hey length supported by the algorithm is used. |
useLargestBlock | If true then algorithm parameters are set (if necessary) in such a way that the largest hey length supported by the algorithm is used. |
Referenced by IG.Crypto.UtilCrypto.DecryptPlain(), and IG.Crypto.UtilCrypto.EncryptPlain().
|
inlinestatic |
Encrypts the specified byte array by a symmetric encryption algorithm and writes encrypted data to the specified output stream that must be open for writing.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be encrypted. |
outputStream | Stream to which decrypted data is written. The stream must be open for writing and should be closed by the caller of this method. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
SaltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmPlain().
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Decrypts the specified byte array by a symmetric algorithm and writes decrypted data to the specified output stream.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be decrypted. |
outputStream | Stream to which decrypted data is written. The stream must be open for writing and should be closed by the caller of this method. |
key | Secret key used to decrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmPlain().
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Encrypts the specified byte array by a symmetric encryption algorithm and returns encrypted bytes.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be encrypted. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
SaltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
|
inlinestatic |
Decrypts the specified byte array by a symmetric algorithm and returns decrypted data.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
data | Data to be decrypted. |
key | Secret key used to decrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
|
inlinestatic |
Encrypts the specified string, using the specified symmetric algorithm, key, and initialization vector, and returns the Base64 string representation of the encrypted bytes.
stringToEncrypt | String that is encrypted. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with <param name="algorithmType", or null. |
SaltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector.
cipherText | Base64 string representation of the byte array containing the encrypted original string. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with <param name="algorithmType", or null. |
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Encrypts the specified string to a byte array, using the specified symmetric algorithm, key, and initialization vector.
stringToEncrypt | String that is encrypted. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with <param name="algorithmType", or null. |
SaltBytes | Salt that is prepended the data before encryption. |
useLargestKey | If true then the algorithm will be modified in such a way that it uses the largest possible key for this kind of algorithm. |
useLargestBlock | If true then the algorithm will be modified in such a way that it uses the largest possible block for this kind of algorithm. |
|
inlinestatic |
Derypts the specified string from encryted byte array, using the specified symmetric algorithm, key, and initialization vector.
cipherText | Byte array containing the encrypted original string. |
key | Secret key used in encryption. |
initializationVector | Initialization vector used in encryption. Necessary for stronger encryption (othervise repeating input blocks would cause repeating output blocks). |
algorithmType | Type of the algorithm used. |
algorithm | Agorithm used for encryption. Must be consistend with <param name="algorithmType", or null. |
numSaltBytes | Length of salt, which must be accounted for when decrypting. |
useLargestKey | If true then the algorithm is modified (if necessary) in such a way that the largest possible key size is used. |
useLargestBlock | If true then the algorithm is modified in such a way that the largest possible block size is used. |
|
inlinestatic |
Encrypts the data from the specified input stream by a symmetric encryption algorithm and writes encrypted data to the specified output stream.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputStream | Input stream from which data is encrypted. The stream must be open for reading and should be closed by the caller of this method. |
outputStream | Stream to which encrypted data is written. The stream must be open for writing and should be closed by the caller of this method. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmPlain().
|
inlinestatic |
Decrypts the data from the specified input stream by a symmetric encryption algorithm and writes decrypted data to the specified output stream.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputStream | Input stream from which data is decrypted. The stream must be open for reading and should be closed by the caller of this method. |
outputStream | Stream to which decrypted data is written. The stream must be open for writing and should be closed by the caller of this method. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
References IG.Crypto.UtilCrypto.PrepareSymmetricAllgorithmPlain().
|
inlinestatic |
Encrypts the data from the specified input file by a symmetric encryption algorithm and writes encrypted data to the specified output file.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputFilePath | Path to the input file from which data is encrypted. The file must be exist and be readable. |
deletedFilePath | Path to the output file to which encrypted data is written. The file must be writable and will be overwritten if it already exists. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Decrypts the data from the specified input file by a symmetric encryption algorithm and writes decrypted data to the specified output file.
If the algorithm is not specified then it is provided by the system, but in this case both the key and the initialization vector must be specified.
If algorithm is specified then the key and initialization vector can be generated by the algorithm and retrieved from the algorithm after the call.
inputFilePath | Path to the input file from which data is encrypted. The file must be exist and be readable. |
deletedFilePath | Path to the output file to which encrypted data is written. The file must be writable and will be overwritten if it already exists. |
key | Secret key used to encrypt the data. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
IV | Initialization vector. It can be public and stored together with encrypted data, but it is advised that the vecor is randomly generated for each session or each encryption. |
If not specified but algorithm is specified, it is randomly generated and stored by the algorithm.
algorithmType | Type of the algorithm used. |
algorithm | Algoritgm used. |
If specified then key and IV can be generated and stored by the algorithm. Algorithm type must correspond to the specified type.
If not specified then it is generated anew.
bufferSize | Size of the intermediate buffer through which we read from input and write to output stream. Buffer makes possible to work on very large streams efficiently. |
useLargestKey | If true then algorithm is eventually modified in such a way that it uses the largest possible key size. |
useLargestBlock | If true then algorithm is eventually modified in such a way that it uses the largest possible block size. |
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll().
|
inlinestatic |
Returns all asymmetric encryption algorithm types contained in the enumeration AsymmetricAlgorithmType
References IG.Lib.Util.LockGlobal.
|
inlinestatic |
Returns the AsymmetricAlgorithmType value corresponding to the specified string.
typeString | String that represents the asymmetric encryption algorithm type. |
Referenced by IG.Crypto.CryptoManager.ParseCommandlineParameters().
|
inlinestatic |
Returns the asymmetric encryption algorithm type, i.e. an enumeration of type SymmetricAlgorithmType, for the specified asymmetric encryption algorithm object.
algorithmObject | Asymmetric algorithm object for which type enumeration is returned. |
|
inlinestatic |
Returns standard string representation of the specified asymmetric encryption algorithm type.
algorithmType | Asymmetric encryption algorithm type whose string representation is returned. |
|
inlinestatic |
Returns the appropriate asymmetric algorithm according to the specified hash type, or null if the type is not recognized or the method is not implemented for that type.
algorithmType | Specification of the asymmetric encryption algorithm type. |
|
inlinestatic |
Returns true if the specified asymmetric encryption algorithm corresponds the type specification, false otherwise.
If the specified algorithm is null or the specified type is unknown then false is returned.
algorithmType | Specification of the asymmetric encryption algorithm type. |
algorithm | Algorithm that is checked for type correctness. |
|
inlinestatic |
Returns the largest possible key size, in bits, for the spcified symmetric encryption algorithm.
algorithm | Algorithm whose largest possible key size is returned. |
|
inlinestaticprivate |
On the specified asymmetric encryption algorithm, sets the largest possible key size, in bits, for the corresponding asymmetric encryption algorithm.
algorithm | Algorithm whose largest possible key size is returned. |
|
inlinestatic |
For the specified asymmetric encryption algorithm, this function takes the specified key and checks if the key is of valid size. If yes then the unmodified key is returned, otherwise the modified key that fits the required size is returned.
initializationVector | Original key provided for the algorithm. |
algorithm | Asymmetric algorithm that is used for encryption/decryption. Object is used to query and eventually set the key sizes. |
useLargestBlock | If true then the specified algorithm is first modified in such a way that it uses the maximal possible key length for the specific kind of algorithm. |
A key that is of valid size for the algorithm.
If the original key size matches the required one, the key is unmodified.
If the original key is larger than the required one, the first bytes of the provided key are used in the returned key.
If the provided key is smaller than the erquired key size then bytes in the returned key are cyclically repeated bytes from the original key.
|
inlinestatic |
Returns the specified standard IGLib salt string.
There are several uses of salt strings:
- they are appended or prepended to passwords before hashing.
whichSalt | Index of the standard IGLib salt string. |
|
inlinestatic |
Returns the number of standard IGLib salt strings.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
An array of standard IGLib salt suffices.
Warnings:
- Hard coding salts is generally not OK, it is important that salts are random and salts can be stored together with enxrypted data.
- This array should not be modifiable.
- Elements of this array may not change over time. Only new elements can be added.
|
staticget |
Output level for static methods of the current utility class.
Warning: This field can be removed at any time.
|
staticget |
Locking object for static methods and properties of this class.
|
staticget |
Gets the character encoding that is used for calculating hashes of strings.
About thread safety (Enncoding classes should be stateless):
http://stackoverflow.com/questions/3024384/thread-safety-and-system-text-encoding-in-c-sharp
Referenced by IG.Crypto.CryptoManager.AppEncryptSymmetricAll(), IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration_OLD_TO_DELETE_LATER(), and IG.Crypto.CryptoManager.ResolvePasswordParameters().
|
staticgetprivate |
Object used to generate random bytes.
Object is created on demand (layzy evaluation). Ony one object is used through appllication lifetime.