private CodecDll() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _dll = new WindowsDll("encoding.dll"); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { _dll = new LinuxDll("encoding.so"); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { throw new NotSupportedException($"MaxOS is not supported yet"); } _generateKey = (GenerateKeyDelegate)_dll.GetDelegate <GenerateKeyDelegate>("GenerateKey"); _encodeFile = (EncodeFileDelegate)_dll.GetDelegate <EncodeFileDelegate>("EncodeFile"); _decodeFile = (DecodeFileDelegate)_dll.GetDelegate <DecodeFileDelegate>("DecodeFile"); _computeHash = (ComputeHashDelegate)_dll.GetDelegate <ComputeHashDelegate>("ComputeHash"); _computeDataHash = (ComputeDataHashDelegate)_dll.GetDelegate <ComputeDataHashDelegate>("ComputeDataHash"); }
public HashAlgorithmWrapper(IDigest bciDigest) { HashAlgorithmObject = bciDigest; ComputeHashDelegateInstance = BouncyCastleComputeHashDelegateProvider; HashSizeInBits = bciDigest.GetDigestSize() * 8; // GetDigestSize() returns a number of bytes }
public HashAlgorithmWrapper(HashAlgorithm hashAlg) { HashAlgorithmObject = hashAlg; ComputeHashDelegateInstance = hashAlg.ComputeHash; HashSizeInBits = hashAlg.HashSize; // HashAlg.HashSize is measured in bits }
public HashAlgorithmWrapper( IDigest BCIDigest ) { HashAlgorithmObject = BCIDigest; ComputeHashDelegateInstance = BouncyCastleComputeHashDelegateProvider; HashSizeInBits = BCIDigest.GetDigestSize() * 8; // GetDigestSize() returns a number of bytes }
public HashAlgorithmWrapper( HashAlgorithm HashAlg ) { HashAlgorithmObject = HashAlg; ComputeHashDelegateInstance = HashAlg.ComputeHash; HashSizeInBits = HashAlg.HashSize; // HashAlg.HashSize is measured in bits }