CryptoAbstraction
using Renci.SshNet.Security.Cryptography;
using SshNet.Security.Cryptography;
using System.Security.Cryptography;
namespace Renci.SshNet.Abstractions
{
internal static class CryptoAbstraction
{
private static readonly RandomNumberGenerator Randomizer = CreateRandomNumberGenerator();
public static byte[] GenerateRandom(int length)
{
byte[] obj = new byte[length];
GenerateRandom(obj);
return obj;
}
public static void GenerateRandom(byte[] data)
{
Randomizer.GetBytes(data);
}
public static RandomNumberGenerator CreateRandomNumberGenerator()
{
return new RNGCryptoServiceProvider();
}
public static MD5 CreateMD5()
{
return new MD5();
}
public static SHA1 CreateSHA1()
{
return new SHA1Managed();
}
public static SHA256 CreateSHA256()
{
return new SHA256Managed();
}
public static SHA384 CreateSHA384()
{
return new SHA384();
}
public static SHA512 CreateSHA512()
{
return new SHA512();
}
public static RIPEMD160 CreateRIPEMD160()
{
return new RIPEMD160();
}
public static HMACMD5 CreateHMACMD5(byte[] key)
{
return new HMACMD5(key);
}
public static HMACMD5 CreateHMACMD5(byte[] key, int hashSize)
{
return new HMACMD5(key, hashSize);
}
public static System.Security.Cryptography.HMACSHA1 CreateHMACSHA1(byte[] key)
{
return new System.Security.Cryptography.HMACSHA1(key);
}
public static Renci.SshNet.Security.Cryptography.HMACSHA1 CreateHMACSHA1(byte[] key, int hashSize)
{
return new Renci.SshNet.Security.Cryptography.HMACSHA1(key, hashSize);
}
public static System.Security.Cryptography.HMACSHA256 CreateHMACSHA256(byte[] key)
{
return new System.Security.Cryptography.HMACSHA256(key);
}
public static Renci.SshNet.Security.Cryptography.HMACSHA256 CreateHMACSHA256(byte[] key, int hashSize)
{
return new Renci.SshNet.Security.Cryptography.HMACSHA256(key, hashSize);
}
public static HMACSHA384 CreateHMACSHA384(byte[] key)
{
return new HMACSHA384(key);
}
public static HMACSHA384 CreateHMACSHA384(byte[] key, int hashSize)
{
return new HMACSHA384(key, hashSize);
}
public static HMACSHA512 CreateHMACSHA512(byte[] key)
{
return new HMACSHA512(key);
}
public static HMACSHA512 CreateHMACSHA512(byte[] key, int hashSize)
{
return new HMACSHA512(key, hashSize);
}
public static HMACRIPEMD160 CreateHMACRIPEMD160(byte[] key)
{
return new HMACRIPEMD160(key);
}
}
}