IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
Unit tests for cryptographic operations. More...
Public Member Functions | |
void | QuickCustomTestingOfVariousThings () |
Quick custom tests. More... | |
void | Prerequisites () |
Tests conversion of numeric values to byte array and back. More... | |
void | HashTypes () |
Test of hashing algorithm types (conversion to strings and back). More... | |
void | HashStringMd5 () |
Test of MD5 hashing function. More... | |
void | HashStringSha1 () |
Test of SHA-1 hashing function. More... | |
void | HashStringSha256 () |
Test of SHA-256 hashing function. More... | |
void | HashStringSha512 () |
Test of SHA-512 hashing function. More... | |
void | HashStringSaltedMd5 () |
Test of MD5 salted hashing. More... | |
void | HashStringSaltedSha1 () |
Test of SHA1 salted hashing. More... | |
void | HashStringSaltedSha256 () |
Test of SHA256 salted hashing. More... | |
void | HashStringSaltedSHA512 () |
Test of SHA512 salted hashing. More... | |
void | SymmetricAlgorithmTypes () |
Test of symmetric encryption algorithm types (conversion to strings and back). More... | |
void | SymmetricEncryptionStringToBytesPlain () |
Test of symmetric encryption of strings. More... | |
void | SymmetricEncryptionStringPlain () |
Test of symmetric encryption of strings. More... | |
void | SymmetricEncryptionFilesPlain () |
Test of symmetric encryption of strings. More... | |
void | SymmetricEncryptionStringPlainRandom () |
Test of symmetric encryption/decryption of randomly generated unicode strings. More... | |
void | SymmetricEncryptionStringBase () |
Test of symmetric encryption of strings. More... | |
void | Test_EncryptStringTobytes_DecryptStringFromBytes () |
byte[] | EncryptStringToBytes (string plainText, byte[] Key, byte[] IV, SymmetricAlgorithm algorithm) |
string | DecryptStringFromBytes (byte[] cipherText, byte[] Key, byte[] IV, SymmetricAlgorithm algorithm=null) |
void | AsymmetricAlgorithmTypes () |
Test of symmetric encryption algorithm types (conversion to strings and back). More... | |
void | QuickCustomTestingOfVariousThings () |
Quick custom tests. More... | |
void | Prerequisites () |
Tests conversion of numeric values to byte array and back. More... | |
void | HashTypes () |
Test of hashing algorithm types (conversion to strings and back). More... | |
void | HashStringMd5 () |
Test of MD5 hashing function. More... | |
void | HashStringSha1 () |
Test of SHA-1 hashing function. More... | |
void | HashStringSha256 () |
Test of SHA-256 hashing function. More... | |
void | HashStringSha512 () |
Test of SHA-512 hashing function. More... | |
void | HashStringSaltedMd5 () |
Test of MD5 salted hashing. More... | |
void | HashStringSaltedSha1 () |
Test of SHA1 salted hashing. More... | |
void | HashStringSaltedSha256 () |
Test of SHA256 salted hashing. More... | |
void | HashStringSaltedSHA512 () |
Test of SHA512 salted hashing. More... | |
void | SymmetricAlgorithmTypes () |
Test of symmetric encryption algorithm types (conversion to strings and back). More... | |
void | SymmetricEncryptionStringToBytesPlain () |
Test of symmetric encryption of strings. More... | |
void | SymmetricEncryptionStringPlain () |
Test of symmetric encryption of strings. More... | |
void | SymmetricEncryptionFilesPlain () |
Test of symmetric encryption of strings. More... | |
void | SymmetricEncryptionStringPlainRandom () |
Test of symmetric encryption/decryption of randomly generated unicode strings. More... | |
void | SymmetricEncryptionStringBase () |
Test of symmetric encryption of strings. More... | |
void | Test_EncryptStringTobytes_DecryptStringFromBytes () |
byte[] | EncryptStringToBytes (string plainText, byte[] Key, byte[] IV, SymmetricAlgorithm algorithm) |
string | DecryptStringFromBytes (byte[] cipherText, byte[] Key, byte[] IV, SymmetricAlgorithm algorithm=null) |
void | AsymmetricAlgorithmTypes () |
Test of symmetric encryption algorithm types (conversion to strings and back). More... | |
Static Public Member Functions | |
static string | GetTempFilePath (string extension) |
Attemps to create a unique temporary file name with specified extension. More... | |
static byte[] | EncryptTextToMemory (string Data, byte[] Key, byte[] IV, SymmetricAlgorithm algorithm=null) |
static string | DecryptTextFromMemory (byte[] Data, byte[] Key, byte[] IV, SymmetricAlgorithm algorithm=null) |
static string | GetTempFilePath (string extension) |
Attemps to create a unique temporary file name with specified extension. More... | |
static byte[] | EncryptTextToMemory (string Data, byte[] Key, byte[] IV, SymmetricAlgorithm algorithm=null) |
static string | DecryptTextFromMemory (byte[] Data, byte[] Key, byte[] IV, SymmetricAlgorithm algorithm=null) |
Protected Attributes | |
int | OutputLevel = 1 |
Private Attributes | |
int | MinHashedStringLength = 20 |
int | MinSaltLength = 8 |
int | MinHashLength = 5 |
int | MaxHashIterations = 5 |
string | TestString1 |
string | Salt1 = "kj49kdleedjgkdDgjirlfDfkljor38k8F90.,<>/-0+=6';[]a547" |
string | HashString_MD5_TestString1 = "cc757dfb670ddd0975a2021092b36e4b" |
string | HashString_SHA1_TestString1 = "8b34630c081b223e99907c6bab516dadc4f66b30" |
string | HashString_SHA256_TestString1 = "a0f3b7165ba8bb0712e7e29057ade112170b833596482687aaad1bfe24131327" |
string | HashString_SHA512_TestString1 = "d7ddf25dea6a1d3dda95238f212b2e364830126b480515f4c016bd9a8c61555fcd33c69f412faede1e083b85e0410a2869c0fe1a720fd28dd7d677780ab01a31" |
string | SaltedHashString_MD5_TestString0 = "0b3d1bf6ad0bff801c46e21bccc7c39b" |
string | SaltedHashHashString_SHA1_TestString0 = "b2833abc9422fb995fb2b840c4e58a99231421c3" |
string | SaltedHashString_SHA256_TestString0 = "a99e37a873466000f95579afdf9bd54a289efec531730f786a2c9360cd475896" |
string | SaltedHashString_SHA512_TestString0 = "3eb48ca6a2ce36f5a2f57def0bc40f07ec90cc0398c667464a27756bca5f9fb99fbb63b36a0d8a1d36e582741ee83fc5dd8d78d04b04be6478a122e0da7b1585" |
string | SaltedHashString_MD5_TestString1 = "39af402506b3041569a17af3875bcb96" |
string | SaltedHashString_SHA1_TestString1 = "d840bfc4a659a59f3302ade546590c47bf3eeffa" |
string | SaltedHashString_SHA256_TestString1 = "83956ed273bdf27ae74e151dcbb7d2d2fbcb895b39b14b10ba65e0a8aee8292f" |
string | SaltedHashString_SHA512_TestString1 = "fd8af3cd3f50e617255ebec9d3d9f222171eb691773c12adbb884355dc342c214455d04a82088d94f83407742a4c6759f98d43bce95db4179be509b37a929408" |
string | SymmetricPassword1 = "asdfghjklqwertyuio" |
string | SymmetricInitializationVector1 = "zxcvbnmasdfgher" |
Unit tests for cryptographic operations.
$A Igor May09 Dec14;
|
inline |
Quick custom tests.
References IG.Crypto.PasswordAlgorithmBase.GetBytes(), IG.Crypto.PasswordAlgorithmBase.Init(), and IG.Lib.Util.ToHexString().
|
inline |
Tests conversion of numeric values to byte array and back.
See e.g. Util.ToByteArray(long, ref [], int) or Util.FromByteArray(byte[] bytes, out long val, bool preciseLength, int startIndex).
References IG.Lib.Util.FromByteArray(), IG.Num.RandomGeneratorSystem.Next(), IG.Num.RandomGeneratorSystem.NextDouble(), IG.Lib.Util.SizeOf(), IG.Lib.Util.ToByteArray(), and IG.Lib.Util.ToHexString().
|
inline |
Test of hashing algorithm types (conversion to strings and back).
References IG.Crypto.UtilCrypto.GetHashType(), IG.Crypto.UtilCrypto.GetHashTypes(), and IG.Crypto.UtilCrypto.HashTypeToString().
|
inline |
Test of MD5 hashing function.
References IG.Crypto.UtilCrypto.GetStringHashMd5Hex().
|
inline |
Test of SHA-1 hashing function.
References IG.Crypto.UtilCrypto.GetStringHashSha1Hex().
|
inline |
Test of SHA-256 hashing function.
References IG.Crypto.UtilCrypto.GetStringHashSha256Hex().
|
inline |
Test of SHA-512 hashing function.
References IG.Crypto.UtilCrypto.GetStringHashSha512Hex().
|
inline |
Test of MD5 salted hashing.
References IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetHashMd5Hex(), and IG.Crypto.UtilCrypto.GetStringSaltedHashMd5Hex().
|
inline |
Test of SHA1 salted hashing.
References IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetHashSha1Hex(), and IG.Crypto.UtilCrypto.GetStringSaltedHashSha1Hex().
|
inline |
Test of SHA256 salted hashing.
References IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetHashSha256Hex(), and IG.Crypto.UtilCrypto.GetStringSaltedHashSha256Hex().
|
inline |
Test of SHA512 salted hashing.
References IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetHashSha512Hex(), and IG.Crypto.UtilCrypto.GetStringSaltedHashSha512Hex().
|
inline |
Test of symmetric encryption algorithm types (conversion to strings and back).
References IG.Crypto.UtilCrypto.GetSymmetricAlgorithmType(), IG.Crypto.UtilCrypto.GetSymmetricAlgorithmTypes(), and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inline |
Test of symmetric encryption of strings.
References IG.Crypto.UtilCrypto.DecryptStringFromBytesPlain(), IG.Crypto.UtilCrypto.EncryptStringToBytesPlain(), IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString(), and IG.Lib.Util.ToHexString().
|
inline |
Test of symmetric encryption of strings.
References IG.Crypto.UtilCrypto.DecryptStringPlain(), IG.Crypto.UtilCrypto.EncryptStringPlain(), IG.Crypto.UtilCrypto.GetRandomBytes(), and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inlinestatic |
Attemps to create a unique temporary file name with specified extension.
extension | Extension of the temporary file. |
|
inline |
Test of symmetric encryption of strings.
References IG.Crypto.UtilCrypto.DecryptFilePlain(), IG.Crypto.UtilCrypto.EncryptFilePlain(), IG.Crypto.UtilCrypto.GetRandomBytes(), and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inline |
Test of symmetric encryption/decryption of randomly generated unicode strings.
References IG.Crypto.UtilCrypto.DecryptStringPlain(), IG.Crypto.UtilCrypto.EncryptStringPlain(), IG.Crypto.UtilCrypto.GetRandomBytes(), IG.Lib.UtilStr.RandomUnicodeString(), and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inline |
Test of symmetric encryption of strings.
References IG.Crypto.UtilCrypto.DecryptStringPlain(), IG.Crypto.UtilCrypto.EncryptStringPlain(), IG.Crypto.UtilCrypto.GetRandomBytes(), IG.Crypto.UtilCrypto.StringEncoding, and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inline |
Test of symmetric encryption algorithm types (conversion to strings and back).
References IG.Crypto.UtilCrypto.AsymmetricAlgorithmTypeToString(), IG.Crypto.UtilCrypto.GetAsymmetricAlgorithmType(), and IG.Crypto.UtilCrypto.GetAsymmetricAlgorithmTypes().
|
inline |
Quick custom tests.
References IG.Crypto.PasswordAlgorithmBase.GetBytes(), IG.Crypto.PasswordAlgorithmBase.Init(), and IG.Lib.Util.ToHexString().
|
inline |
Tests conversion of numeric values to byte array and back.
See e.g. Util.ToByteArray(long, ref [], int) or Util.FromByteArray(byte[] bytes, out long val, bool preciseLength, int startIndex).
References NUnit.Framework.Is.EqualTo(), IG.Lib.Util.FromByteArray(), IG.Num.RandomGeneratorSystem.Next(), IG.Num.RandomGeneratorSystem.NextDouble(), IG.Lib.Util.SizeOf(), NUnit.Framework.Assert.That(), IG.Lib.Util.ToByteArray(), IG.Lib.Util.ToHexString(), and NUnit.Framework.Is.True.
|
inline |
Test of hashing algorithm types (conversion to strings and back).
References IG.Crypto.UtilCrypto.GetHashType(), IG.Crypto.UtilCrypto.GetHashTypes(), IG.Crypto.UtilCrypto.HashTypeToString(), NUnit.Framework.Assert.That(), and NUnit.Framework.Is.True.
|
inline |
Test of MD5 hashing function.
References NUnit.Framework.Is.EqualTo(), IG.Crypto.UtilCrypto.GetStringHashMd5Hex(), and NUnit.Framework.Assert.That().
|
inline |
Test of SHA-1 hashing function.
References NUnit.Framework.Is.EqualTo(), IG.Crypto.UtilCrypto.GetStringHashSha1Hex(), and NUnit.Framework.Assert.That().
|
inline |
Test of SHA-256 hashing function.
References NUnit.Framework.Is.EqualTo(), IG.Crypto.UtilCrypto.GetStringHashSha256Hex(), and NUnit.Framework.Assert.That().
|
inline |
Test of SHA-512 hashing function.
References NUnit.Framework.Is.EqualTo(), IG.Crypto.UtilCrypto.GetStringHashSha512Hex(), and NUnit.Framework.Assert.That().
|
inline |
Test of MD5 salted hashing.
References NUnit.Framework.Is.EqualTo(), IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetHashMd5Hex(), IG.Crypto.UtilCrypto.GetStringSaltedHashMd5Hex(), and NUnit.Framework.Assert.That().
|
inline |
Test of SHA1 salted hashing.
References NUnit.Framework.Is.EqualTo(), IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetHashSha1Hex(), IG.Crypto.UtilCrypto.GetStringSaltedHashSha1Hex(), and NUnit.Framework.Assert.That().
|
inline |
Test of SHA256 salted hashing.
References NUnit.Framework.Is.EqualTo(), IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetHashSha256Hex(), IG.Crypto.UtilCrypto.GetStringSaltedHashSha256Hex(), and NUnit.Framework.Assert.That().
|
inline |
Test of SHA512 salted hashing.
References NUnit.Framework.Is.EqualTo(), IG.Lib.Util.FromHexString(), IG.Crypto.UtilCrypto.GetHashSha512Hex(), IG.Crypto.UtilCrypto.GetStringSaltedHashSha512Hex(), and NUnit.Framework.Assert.That().
|
inline |
Test of symmetric encryption algorithm types (conversion to strings and back).
References IG.Crypto.UtilCrypto.GetSymmetricAlgorithmType(), IG.Crypto.UtilCrypto.GetSymmetricAlgorithmTypes(), NUnit.Framework.Assert.IsTrue(), and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inline |
Test of symmetric encryption of strings.
References IG.Crypto.UtilCrypto.DecryptStringFromBytesPlain(), IG.Crypto.UtilCrypto.EncryptStringToBytesPlain(), NUnit.Framework.Is.EqualTo(), IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString(), NUnit.Framework.Assert.That(), and IG.Lib.Util.ToHexString().
|
inline |
Test of symmetric encryption of strings.
References NUnit.Framework.Assert.AreEqual(), IG.Crypto.UtilCrypto.DecryptStringPlain(), IG.Crypto.UtilCrypto.EncryptStringPlain(), IG.Crypto.UtilCrypto.GetRandomBytes(), and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inlinestatic |
Attemps to create a unique temporary file name with specified extension.
extension | Extension of the temporary file. |
|
inline |
Test of symmetric encryption of strings.
References NUnit.Framework.Assert.AreEqual(), NUnit.Framework.Assert.AreNotEqual(), IG.Crypto.UtilCrypto.DecryptFilePlain(), IG.Crypto.UtilCrypto.EncryptFilePlain(), IG.Crypto.UtilCrypto.GetRandomBytes(), and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inline |
Test of symmetric encryption/decryption of randomly generated unicode strings.
References NUnit.Framework.Assert.AreEqual(), IG.Crypto.UtilCrypto.DecryptStringPlain(), IG.Crypto.UtilCrypto.EncryptStringPlain(), IG.Crypto.UtilCrypto.GetRandomBytes(), IG.Lib.UtilStr.RandomUnicodeString(), and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inline |
Test of symmetric encryption of strings.
References NUnit.Framework.Assert.AreEqual(), IG.Crypto.UtilCrypto.DecryptStringPlain(), IG.Crypto.UtilCrypto.EncryptStringPlain(), IG.Crypto.UtilCrypto.GetRandomBytes(), IG.Crypto.UtilCrypto.StringEncoding, and IG.Crypto.UtilCrypto.SymmetricAlgorithmTypeToString().
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inline |
Test of symmetric encryption algorithm types (conversion to strings and back).
References IG.Crypto.UtilCrypto.AsymmetricAlgorithmTypeToString(), IG.Crypto.UtilCrypto.GetAsymmetricAlgorithmType(), IG.Crypto.UtilCrypto.GetAsymmetricAlgorithmTypes(), and NUnit.Framework.Assert.IsTrue().
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |