Crypto.CryptoManager.SetEncryptionLevel C# (CSharp) Méthode

SetEncryptionLevel() public méthode

Sets or resets the encryption level for the encryption instance
public SetEncryptionLevel ( CryptoLevel keysize = CryptoLevel.AES256 ) : void
keysize CryptoLevel The encryption level as an CryptoLevel enum
Résultat void
        public void SetEncryptionLevel(CryptoLevel keysize = CryptoLevel.AES256)
        {
            // update the keySize property with the requested encryption level
            KeySize = keysize;

            // at this time we are utilizing hard-coded values
            ConfigureCryptoInCode();

            // convert the CryptoLevel to an integer to assist calculationg the crypto properties
            m_encryptionBits = KeySize == CryptoLevel.AES256 ? 256 : KeySize == CryptoLevel.AES128 ? 128 : 0;

            // initialize the IV array
            iv_array = new byte[16];

            // initialize the Key array
            key_array = new byte[m_encryptionBits / 8];

            // generate the Crypto Key and IV
            // create the key and Initial Vector from the
            OpenSslCompatDeriveBytes crap = new OpenSslCompatDeriveBytes(m_cryptoSalt, m_nonce, m_cryptoHash, m_cryptoIterations);

            stuff_array = crap.GetBytes((m_encryptionBits / 8) + 16);
            Buffer.BlockCopy(stuff_array, 0, key_array, 0, m_encryptionBits / 8);
            Buffer.BlockCopy(stuff_array, m_encryptionBits / 8, iv_array, 0, 16);
        }