IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.Test.TestCrypto Class Reference

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"
 

Detailed Description

Unit tests for cryptographic operations.

$A Igor May09 Dec14;

Member Function Documentation

void IG.Test.TestCrypto.QuickCustomTestingOfVariousThings ( )
inline
void IG.Test.TestCrypto.Prerequisites ( )
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().

void IG.Test.TestCrypto.HashTypes ( )
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().

void IG.Test.TestCrypto.HashStringMd5 ( )
inline

Test of MD5 hashing function.

References IG.Crypto.UtilCrypto.GetStringHashMd5Hex().

void IG.Test.TestCrypto.HashStringSha1 ( )
inline

Test of SHA-1 hashing function.

References IG.Crypto.UtilCrypto.GetStringHashSha1Hex().

void IG.Test.TestCrypto.HashStringSha256 ( )
inline

Test of SHA-256 hashing function.

References IG.Crypto.UtilCrypto.GetStringHashSha256Hex().

void IG.Test.TestCrypto.HashStringSha512 ( )
inline

Test of SHA-512 hashing function.

References IG.Crypto.UtilCrypto.GetStringHashSha512Hex().

void IG.Test.TestCrypto.HashStringSaltedMd5 ( )
inline
void IG.Test.TestCrypto.HashStringSaltedSha1 ( )
inline
void IG.Test.TestCrypto.HashStringSaltedSha256 ( )
inline
void IG.Test.TestCrypto.HashStringSaltedSHA512 ( )
inline
void IG.Test.TestCrypto.SymmetricAlgorithmTypes ( )
inline
void IG.Test.TestCrypto.SymmetricEncryptionStringToBytesPlain ( )
inline
void IG.Test.TestCrypto.SymmetricEncryptionStringPlain ( )
inline
static string IG.Test.TestCrypto.GetTempFilePath ( string  extension)
inlinestatic

Attemps to create a unique temporary file name with specified extension.

Parameters
extensionExtension of the temporary file.
Returns
The unique file path.
void IG.Test.TestCrypto.SymmetricEncryptionFilesPlain ( )
inline
void IG.Test.TestCrypto.SymmetricEncryptionStringPlainRandom ( )
inline
void IG.Test.TestCrypto.Test_EncryptStringTobytes_DecryptStringFromBytes ( )
inline
byte [] IG.Test.TestCrypto.EncryptStringToBytes ( string  plainText,
byte[]  Key,
byte[]  IV,
SymmetricAlgorithm  algorithm 
)
inline
string IG.Test.TestCrypto.DecryptStringFromBytes ( byte[]  cipherText,
byte[]  Key,
byte[]  IV,
SymmetricAlgorithm  algorithm = null 
)
inline
static byte [] IG.Test.TestCrypto.EncryptTextToMemory ( string  Data,
byte[]  Key,
byte[]  IV,
SymmetricAlgorithm  algorithm = null 
)
inlinestatic
static string IG.Test.TestCrypto.DecryptTextFromMemory ( byte[]  Data,
byte[]  Key,
byte[]  IV,
SymmetricAlgorithm  algorithm = null 
)
inlinestatic
void IG.Test.TestCrypto.AsymmetricAlgorithmTypes ( )
inline
void IG.Test.TestCrypto.QuickCustomTestingOfVariousThings ( )
inline
void IG.Test.TestCrypto.Prerequisites ( )
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.

void IG.Test.TestCrypto.HashTypes ( )
inline
void IG.Test.TestCrypto.HashStringMd5 ( )
inline
void IG.Test.TestCrypto.HashStringSha1 ( )
inline
void IG.Test.TestCrypto.HashStringSha256 ( )
inline
void IG.Test.TestCrypto.HashStringSha512 ( )
inline
void IG.Test.TestCrypto.SymmetricAlgorithmTypes ( )
inline
static string IG.Test.TestCrypto.GetTempFilePath ( string  extension)
inlinestatic

Attemps to create a unique temporary file name with specified extension.

Parameters
extensionExtension of the temporary file.
Returns
The unique file path.
void IG.Test.TestCrypto.SymmetricEncryptionStringPlainRandom ( )
inline
void IG.Test.TestCrypto.Test_EncryptStringTobytes_DecryptStringFromBytes ( )
inline
byte [] IG.Test.TestCrypto.EncryptStringToBytes ( string  plainText,
byte[]  Key,
byte[]  IV,
SymmetricAlgorithm  algorithm 
)
inline
string IG.Test.TestCrypto.DecryptStringFromBytes ( byte[]  cipherText,
byte[]  Key,
byte[]  IV,
SymmetricAlgorithm  algorithm = null 
)
inline
static byte [] IG.Test.TestCrypto.EncryptTextToMemory ( string  Data,
byte[]  Key,
byte[]  IV,
SymmetricAlgorithm  algorithm = null 
)
inlinestatic
static string IG.Test.TestCrypto.DecryptTextFromMemory ( byte[]  Data,
byte[]  Key,
byte[]  IV,
SymmetricAlgorithm  algorithm = null 
)
inlinestatic
void IG.Test.TestCrypto.AsymmetricAlgorithmTypes ( )
inline

Member Data Documentation

int IG.Test.TestCrypto.OutputLevel = 1
protected
int IG.Test.TestCrypto.MinHashedStringLength = 20
private
int IG.Test.TestCrypto.MinSaltLength = 8
private
int IG.Test.TestCrypto.MinHashLength = 5
private
int IG.Test.TestCrypto.MaxHashIterations = 5
private
string IG.Test.TestCrypto.TestString1
private
Initial value:
=
"ikfIkdKk803s;;/[]';';84hf,cbgjkhsz/<>|jfklsafYSitredgKhkPkds9841039-094hgjkfdsuhfjkds,ckfhgsd"
string IG.Test.TestCrypto.Salt1 = "kj49kdleedjgkdDgjirlfDfkljor38k8F90.,<>/-0+=6';[]a547"
private
string IG.Test.TestCrypto.HashString_MD5_TestString1 = "cc757dfb670ddd0975a2021092b36e4b"
private
string IG.Test.TestCrypto.HashString_SHA1_TestString1 = "8b34630c081b223e99907c6bab516dadc4f66b30"
private
string IG.Test.TestCrypto.HashString_SHA256_TestString1 = "a0f3b7165ba8bb0712e7e29057ade112170b833596482687aaad1bfe24131327"
private
string IG.Test.TestCrypto.HashString_SHA512_TestString1 = "d7ddf25dea6a1d3dda95238f212b2e364830126b480515f4c016bd9a8c61555fcd33c69f412faede1e083b85e0410a2869c0fe1a720fd28dd7d677780ab01a31"
private
string IG.Test.TestCrypto.SaltedHashString_MD5_TestString0 = "0b3d1bf6ad0bff801c46e21bccc7c39b"
private
string IG.Test.TestCrypto.SaltedHashHashString_SHA1_TestString0 = "b2833abc9422fb995fb2b840c4e58a99231421c3"
private
string IG.Test.TestCrypto.SaltedHashString_SHA256_TestString0 = "a99e37a873466000f95579afdf9bd54a289efec531730f786a2c9360cd475896"
private
string IG.Test.TestCrypto.SaltedHashString_SHA512_TestString0 = "3eb48ca6a2ce36f5a2f57def0bc40f07ec90cc0398c667464a27756bca5f9fb99fbb63b36a0d8a1d36e582741ee83fc5dd8d78d04b04be6478a122e0da7b1585"
private
string IG.Test.TestCrypto.SaltedHashString_MD5_TestString1 = "39af402506b3041569a17af3875bcb96"
private
string IG.Test.TestCrypto.SaltedHashString_SHA1_TestString1 = "d840bfc4a659a59f3302ade546590c47bf3eeffa"
private
string IG.Test.TestCrypto.SaltedHashString_SHA256_TestString1 = "83956ed273bdf27ae74e151dcbb7d2d2fbcb895b39b14b10ba65e0a8aee8292f"
private
string IG.Test.TestCrypto.SaltedHashString_SHA512_TestString1 = "fd8af3cd3f50e617255ebec9d3d9f222171eb691773c12adbb884355dc342c214455d04a82088d94f83407742a4c6759f98d43bce95db4179be509b37a929408"
private
string IG.Test.TestCrypto.SymmetricPassword1 = "asdfghjklqwertyuio"
private
string IG.Test.TestCrypto.SymmetricInitializationVector1 = "zxcvbnmasdfgher"
private

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