IGLib
1.6.0
The IGLib base library for development of numerical, technical and business applications.
|
Performs high level cryptographic opereratins, such ass reading command-line parameters and performing high-level tasks that can be directly used in application commands (i.e. those commands that are installed on applicaition interpreters). More...
Public Member Functions | |
CryptoManager () | |
CryptoManager (int outputLevel) | |
string | GetFreeParameter (int whichParameter) |
Returns the specified free parameter (obtained from commans-line arguments). More... | |
virtual void | ParseCommandlineParameters (string appName, string[] args) |
Reads parameters for cryptographic operations to be performed from the specified command line. More... | |
virtual void | GetInputFilePaths (ref List< string > inputFilePaths, bool enableWildcards=true, bool addRecursive=true, bool clearBefore=true) |
Gets a list of input files specified by command-line arguments that had been previously parsed by the ParseCommandlineParameters method. More... | |
virtual string | AppEncryptSymmetricBasic (string appName, string[] args) |
Executes command-line action - symmetric encryption of files or text by using BASIC class of methods. More... | |
virtual string | AppDecryptSymmetricBasic (string appName, string[] args) |
Executes command-line action - symmetric decryption of files or text by using BASIC class of methods. More... | |
virtual string | AppEncryptSymmetricPlain (string appName, string[] args) |
Executes command-line action - symmetric encryption of files or text by using PLAIN class of methods. More... | |
virtual string | AppDecryptSymmetricPlain (string appName, string[] args) |
Executes command-line action - symmetric decryption of files or text by using PLAIN class of methods. More... | |
virtual string | AppGetFileHash (string appName, string[] args) |
Executes command-line action - calculation of various hash values of a file. More... | |
virtual string | AppCheckSum (string appName, string[] args) |
Executes command-line action - calculation of various hash values of files or text. More... | |
virtual string | AppConvert (string appName, string[] args) |
Executes command-line action - conversion between different representations of data. More... | |
virtual string | AppCleanFiles (string appName, string[] args) |
Executes command-line action - deletion of eventual redundant files that remained in the file system after cryptographic operations.. More... | |
virtual string | AppTimeKeyGeneration (string appName, string[] args) |
Executes command-line action - measuring time of password generaton algorithms. More... | |
virtual string | AppGetKey (string appName, string[] args) |
Executes command-line action - generates a random initialization vector for symmetric encryption. More... | |
virtual string | AppGetInitializationVector (string appName, string[] args) |
Executes command-line action - generates a random initialization vector for symmetric encryption. More... | |
virtual string | AppGetSalt (string appName, string[] args) |
Executes command-line action - generates a random salt bytes. More... | |
virtual int | ResolvePasswordParameters (int whichFreeParameterkeyLength=0, int whichFreeParameterNumIterations=1) |
Resolves password related parameters such as password, salt, and generated key length. More... | |
![]() | |
CryptoParameters () | |
void | Reset () |
Resets the state. More... | |
bool | IsFlagsSet (params CryptoFlags[] whichFlags) |
Returns true if ALL the specified flags are set, or false if some of them are unset. More... | |
bool | IsAnyFlagSet (params CryptoFlags[] whichFlags) |
Returns true if any of the specified flags is set, or false if none of them is set. More... | |
void | SetFlags (params CryptoFlags[] whichFlags) |
Sets the specified flags. More... | |
void | ClearFlags (CryptoFlags firstFlags, params CryptoFlags[] whichFlags) |
Clears the specified flags. More... | |
void | ClearAllFlags () |
Clears all flags. More... | |
Protected Member Functions | |
virtual void | ReportError (string errorString) |
Used in the current class to report an error. More... | |
virtual void | ReportWarning (string errorString) |
Used in the current class to launch a warning message. More... | |
virtual void | ReportInfo (string errorString) |
Used in the current class to launch an informative message. More... | |
virtual void | WarnAboutPlainEncryption () |
Writes a notification informing that a cryptographic task has been delegated to the CryptoParameters class. More... | |
virtual string | AppEncryptSymmetricAll (string appName, string[] args, bool isDecrypt=false, bool isPlain=false, bool isBasic=false) |
Executes command-line action - symmetric encryption of files or text. More... | |
virtual string | AppKeyGenerationAll (string appName, string[] args, bool measureTimes, int numGenerations) |
Executes command-line action - one of the actions related to key generation. More... | |
Protected Attributes | |
bool | _isDecrypt = false |
bool | _isLargestKey = false |
Properties | |
int | NumAppArguments [get] |
Number of command-line arguments. More... | |
bool | IsDecrypt [get, protected set] |
Whether decryption is perrformed, rather than encryption. More... | |
bool | IsEncrypt [get, protected set] |
Whether decryption is perrformed, rather than encryption. More... | |
bool | IsLargestKey [get, protected set] |
Whether the largest available key size for the algorithm in use is taken. More... | |
List< string > | FreeParameters [get] |
List of free parameters from the parsed command-line. More... | |
int | NumFreeParameters [get] |
Number of free parameters (obtained from commans-line arguments). More... | |
bool | IsInputFormatString [get, set] |
Whether input format is ordinary string. Returns true if there is no binary format specified, false if there is. More... | |
bool | IsInputFormatLongInt [get, protected set] |
bool | IsInputFormat64 [get, protected set] |
Whether input is in form of base-64 encoded byte array. More... | |
bool | IsInputFormatHex [get, protected set] |
Whether input is in form of hexadecimal encoded byte array. More... | |
bool | IsOutputFormatString [get, set] |
Whether output format is ordinary string. Returns true if there is no binary format specified, false if there is. More... | |
bool | IsOutputFormatLongInt [get, protected set] |
Whether output is in form of long integer. More... | |
bool | IsOutputFormat64 [get, protected set] |
Whether output is in form of base-64 encoded byte array. More... | |
bool | IsOutputFormatHex [get, protected set] |
Whether output is in form of hexadecimal encoded byte array. More... | |
![]() | |
CryptoFlags | Flags [get, private set] |
Flags for cryptographic operations performed. More... | |
Private Attributes | |
int | OutputLevel = 2 |
Level of output during operation. More... | |
string | AppName = null |
Application name - name of the application when reading from command line. More... | |
string[] | AppArguments = null |
Last (or currently) read command-line arguments. More... | |
PasswordAlgorithmType | PasswordAlgorithmType = PasswordAlgorithmType.Default |
string | PasswordAlgorithmTypeString = null |
PasswordAlgorithmBase | PasswordAlgorithm = null |
string | AlgorithmTypeString = null |
HashType | HashAlgorithmType = HashType.Default |
SymmetricAlgorithmType | SymmetricAlgorithmType = SymmetricAlgorithmType.Default |
AsymmetricAlgorithmType | AsymmetricAlgorithmType = AsymmetricAlgorithmType.Default |
string | HashValue = null |
bool | IsStringInput = false |
Flag indicating that input are strings or encoded byte arrays, rather than files. More... | |
int | PasswordLength = 0 |
string | PasswordString = null |
byte[] | PasswordBytes = null |
int | SaltLength = 0 |
string | SaltString = null |
byte[] | SaltBytes = null |
int | IvLength = 0 |
string | IvString = null |
byte[] | IvBytes = null |
int | KeyLength = 0 |
byte[] | KeyBytes = null |
int | NumPasswordIterations = 0 |
List< string > | _freeParameters = new List<string>() |
string | ReturnedString = null |
Returned value of command-line application methods. More... | |
bool | IsChecked = false |
Indicates that something is verified, not calculated (or checked in addition, after calculation). More... | |
double | TargetedTotalTime = 0.1 |
string | OutputPath = null |
List< string > | RecursivePathList = new List<string>() |
List< string > | RecursivePathListByLevels = new List<string>() |
List< string > | RecursiveFilePatterns = new List<string>() |
int | RecursiveDirectoryLevels = -1 |
bool | IsRelativePaths = false |
bool | IsAbsolutePaths = false |
bool | IsDeleteOriginal = false |
Specifies whether the original files should be deleted. More... | |
bool | IsDeleteEncrypted = false |
Specifies whether the encrypted files should be deleted. More... | |
bool | IsDeleteDecrypted = false |
Specifies whether the encrypted files should be deleted. More... | |
bool | IsDeleteAllVersions = false |
Specifies whether all versions of a file (e.g. original, encrypted, and decrypted) are allowed to be deleted (e.g. in a file clean-up operation). More... | |
bool | IsForceOverwrites = false |
If true then eventual file overwtires are automatically performed by the relevant operation without asking for user's approval. More... | |
bool | IsSkipOverwrites = false |
If true then eventual file overwrites are automatically skipped by the relevant operation. More... | |
bool | IsForceDeletes = false |
bool | IsSkipDeletes = false |
bool | IsInputFormatEqualOutputFormat = false |
If true then options for input formats and output format are treated interchangeably in the currentt context (e.g. in the current command-line application). More... | |
bool | _isInputFormatLongInt = false |
bool | _isInputFormat64 = false |
bool | _isInputFormatHex = false |
bool | _isOutputFormatLongInt = false |
bool | _isOutputFormat64 = false |
bool | _isOutputFormatHex = false |
Static Private Attributes | |
static int | _numNotifyPlainEncryption = 0 |
Performs high level cryptographic opereratins, such ass reading command-line parameters and performing high-level tasks that can be directly used in application commands (i.e. those commands that are installed on applicaition interpreters).
|
inline |
|
inline |
|
inlineprotectedvirtual |
Used in the current class to report an error.
errorString | Error message that is a part of the output generated by this function. |
|
inlineprotectedvirtual |
Used in the current class to launch a warning message.
errorString | Warning message that is a part of the output generated by this function. |
|
inlineprotectedvirtual |
Used in the current class to launch an informative message.
errorString | Warning message that is a part of the output generated by this function. |
|
inlineprotectedvirtual |
Writes a notification informing that a cryptographic task has been delegated to the CryptoParameters class.
|
inline |
Returns the specified free parameter (obtained from commans-line arguments).
whichParameter | Index of the free parameter to be returned. |
|
inlinevirtual |
Reads parameters for cryptographic operations to be performed from the specified command line.
Parameters read from this function can be used by any high level function that actually performs cryptographic operations.
appName | Name of the embedded application for which parameters are read. |
args | Arguments of the embedded application's command. |
References IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetAsymmetricAlgorithmType(), IG.Crypto.UtilCrypto.GetHashType(), IG.Crypto.UtilCrypto.GetPasswordAlgorithmType(), and IG.Crypto.UtilCrypto.GetSymmetricAlgorithmType().
|
inlinevirtual |
Gets a list of input files specified by command-line arguments that had been previously parsed by the ParseCommandlineParameters method.
inputFilePaths | List where the obtained input file paths are stored. |
enableWildcards | If true (which is default) then file paths listed as free parameters will be resolved by expanding wildcard characters. |
addRecursive | If true (which is default) then files obtained by recursive directory listings are also included. |
clearBefore | If true (which is default) then the list inputFilePaths is cleared before operation. If false then extracted file paths are added to the eventual existing items already on the list. This is an untypical situation and there will rarely bee any need for this. |
References IG.Lib.UtilSystem.GetAbsolutePath(), IG.Lib.UtilSystem.GetRelativePath(), IG.Lib.UtilSystem.ListFilesByLevels(), and IG.Lib.UtilSystem.ListFilesRecursively().
|
inlinevirtual |
Executes command-line action - symmetric encryption of files or text by using BASIC class of methods.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionEncryptBasic().
|
inlinevirtual |
Executes command-line action - symmetric decryption of files or text by using BASIC class of methods.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionDecryptBasic().
|
inlinevirtual |
Executes command-line action - symmetric encryption of files or text by using PLAIN class of methods.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionEncryptPlain().
|
inlinevirtual |
Executes command-line action - symmetric decryption of files or text by using PLAIN class of methods.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionDecryptPlain().
|
inlineprotectedvirtual |
Executes command-line action - symmetric encryption of files or text.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
isDecrypt | If true then decryption is performed, otherwise encryption is performed. |
isPlain | If true then PLAIN class of encryption/decrypton methods is used. |
isBasic | If true then BASIC class of encryption/decryption metthods is used. |
References IG.Lib.StopWatch1.CpuTime, IG.Crypto.UtilCrypto.DecryptFilePlain(), IG.Crypto.UtilCrypto.DecryptPlain(), IG.Crypto.UtilCrypto.DecryptStringPlain(), IG.Crypto.UtilCrypto.EncryptFilePlain(), IG.Crypto.UtilCrypto.EncryptPlain(), IG.Crypto.UtilCrypto.EncryptStringPlain(), IG.Lib.Util.FromHexString(), IG.Lib.UtilConsole.Read(), IG.Lib.UtilConsole.ReadPwd(), IG.Lib.StopWatch1.Start(), IG.Lib.StopWatch1.Stop(), IG.Crypto.UtilCrypto.StringEncoding, IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString(), IG.Lib.StopWatch1.Time, IG.Lib.Util.ToHexString(), IG.Lib.StopWatch1.TotalCpuTime, and IG.Lib.StopWatch1.TotalTime.
|
inlinevirtual |
Executes command-line action - calculation of various hash values of a file.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
References IG.Crypto.UtilCrypto.GetFileHashMd5Hex(), IG.Crypto.UtilCrypto.GetFileHashSha1Hex(), IG.Crypto.UtilCrypto.GetFileHashSha256Hex(), IG.Crypto.UtilCrypto.GetFileHashSha512Hex(), IG.Lib.UtilConsole.Read(), and IG.Lib.UtilStr.ToBoolean().
Referenced by IG.Script.ScriptAppBase.CryptoFunctionGetFileHash().
|
inlinevirtual |
Executes command-line action - calculation of various hash values of files or text.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
References IG.Crypto.UtilCrypto.CheckFileHashHex(), IG.Crypto.UtilCrypto.CheckHashHex(), IG.Crypto.UtilCrypto.CheckStringHashHex(), IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetFileHashHex(), IG.Crypto.UtilCrypto.GetHashHex(), IG.Crypto.UtilCrypto.GetStringHashHex(), IG.Crypto.UtilCrypto.ParseHashFile(), IG.Lib.UtilConsole.Read(), and IG.Lib.Util.ToByteArray().
Referenced by IG.Script.ScriptAppBase.CryptoFunctionCheckSum().
|
inlinevirtual |
Executes command-line action - conversion between different representations of data.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
References IG.Lib.Util.FromHexString(), IG.Lib.Util.ToByteArray(), and IG.Lib.Util.ToHexString().
Referenced by IG.Script.ScriptAppBase.CryptoFunctionConvert().
|
inlinevirtual |
Executes command-line action - deletion of eventual redundant files that remained in the file system after cryptographic operations..
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
References IG.Lib.UtilConsole.Read().
Referenced by IG.Script.ScriptAppBase.CryptoFunctionCleanFiles().
|
inlinevirtual |
Executes command-line action - measuring time of password generaton algorithms.
Key generation algorithm type and other parameters such as password and salt are determined by command-line options.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionTimeKeyGeneration().
|
inlinevirtual |
Executes command-line action - generates a random initialization vector for symmetric encryption.
Key generation algorithm type and other parameters such as password and salt are determined by command-line options.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionGetKey().
|
inlinevirtual |
Executes command-line action - generates a random initialization vector for symmetric encryption.
Key generation algorithm type and other parameters such as password and salt are determined by command-line options.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionGetInitializationVector().
|
inlinevirtual |
Executes command-line action - generates a random salt bytes.
Key generation algorithm type and other parameters such as password and salt are determined by command-line options.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
Referenced by IG.Script.ScriptAppBase.CryptoFunctionGetSalt().
|
inlinevirtual |
Resolves password related parameters such as password, salt, and generated key length.
Paremeters that determine which free paremeters map to password-related parameters such as key length and number of iterations of key generation algorithm, must fill free parameters up to the specified index.
whichFreeParameterkeyLength | Index of free parameter that can eventually represent the key length. If less than 0 then key length can not be specified by free parameters. |
whichFreeParameterNumIterations | Index of free parameter that can eventually represent the number of iterations in password generating algorithm. If less than 0 then number of key generation iterations can not be specified by free parameters. |
References IG.Crypto.UtilCrypto.GetRandomBytes(), and IG.Crypto.UtilCrypto.StringEncoding.
|
inlineprotectedvirtual |
Executes command-line action - one of the actions related to key generation.
appName | Name of the embedded application. |
args | Arguments of the embedded application's command. |
measureTimes | If true then time necessary for key generation with given parameters is measured. Otherwise, the key is actually created. The key can also be used as initialization vector. |
numGenerations | Number of repetirions of key algorithm before return. This makes possible to to generate different outputs e.g. for key, for initialization vector, or for salt. |
References IG.Crypto.PasswordAlgorithmBase.GetBytes(), IG.Crypto.UtilCrypto.GetPasswordAlgorithm(), IG.Crypto.UtilCrypto.GetPasswordAlgorithmType(), IG.Crypto.PasswordAlgorithmBase.Init(), IG.Lib.StopWatch1.TestExecutionTime(), and IG.Lib.Util.ToHexString().
|
staticprivate |
|
private |
Level of output during operation.
|
private |
Application name - name of the application when reading from command line.
|
private |
Last (or currently) read command-line arguments.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
private |
Flag indicating that input are strings or encoded byte arrays, rather than files.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
private |
|
private |
Returned value of command-line application methods.
|
private |
Indicates that something is verified, not calculated (or checked in addition, after calculation).
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Specifies whether the original files should be deleted.
This can refer to deletion of the original file(s) after encryption or decryption, or to deletion of the original file in a group(s) of associated files (original, encrypted, decrypted).
|
private |
Specifies whether the encrypted files should be deleted.
This can refer to deletion of the encrypted file(s) in a group(s) of associated files (original, encrypted, decrypted) during a separate clean-up operation.
|
private |
Specifies whether the encrypted files should be deleted.
This can refer to deletion of the decrypted file(s) in a group(s) of associated files (original, encrypted, decrypted) during a separate clean-up operation.
|
private |
Specifies whether all versions of a file (e.g. original, encrypted, and decrypted) are allowed to be deleted (e.g. in a file clean-up operation).
|
private |
If true then eventual file overwtires are automatically performed by the relevant operation without asking for user's approval.
|
private |
If true then eventual file overwrites are automatically skipped by the relevant operation.
This means that whenever the operation in question would normally have to overwrite an existent file, this is skipped, without even asking ro user's approval. For example, if decryption is performed but some of the original files already exist then these files will not be dcrypted as the operation would heve to overrwrite the original files.
|
private |
|
private |
|
private |
If true then options for input formats and output format are treated interchangeably in the currentt context (e.g. in the current command-line application).
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
getprivate |
Number of command-line arguments.
|
getprotected set |
Whether decryption is perrformed, rather than encryption.
|
getprotected set |
Whether decryption is perrformed, rather than encryption.
|
getprotected set |
Whether the largest available key size for the algorithm in use is taken.
|
getprotected |
List of free parameters from the parsed command-line.
|
get |
Number of free parameters (obtained from commans-line arguments).
|
getsetprivate |
Whether input format is ordinary string. Returns true if there is no binary format specified, false if there is.
|
getprotected set |
|
getprotected set |
Whether input is in form of base-64 encoded byte array.
|
getprotected set |
Whether input is in form of hexadecimal encoded byte array.
|
getsetprivate |
Whether output format is ordinary string. Returns true if there is no binary format specified, false if there is.
|
getprotected set |
Whether output is in form of long integer.
|
getprotected set |
Whether output is in form of base-64 encoded byte array.
|
getprotected set |
Whether output is in form of hexadecimal encoded byte array.