コード例 #1
0
        public TCryptographicCredentials GetCryptographicCredentials <TCryptographicCredentials>(string symmetricAlgorithm, IEnumerable <byte> key, IEnumerable <byte> initialVector, int initialVectorSize = 16) where TCryptographicCredentials : ICryptographicCredentials
        {
            var instance = Activator.CreateInstance <TCryptographicCredentials>();

            instance.SymmetricAlgorithm = symmetricAlgorithm;
            instance.Key = key;

            if (initialVector == null)
            {
                initialVector = _hashingProvider.GetRandomNumberGeneratorBytes(initialVectorSize);
            }

            instance.InitialVector = initialVector;

            return(instance);
        }