private static byte[] EncryptKey(byte[] keyhalf1, byte[] keyhalf2, byte[] derived)
        {
            var derivedhalf1 = derived.SafeSubarray(0, 32);
            var derivedhalf2 = derived.SafeSubarray(32, 32);

            var encryptedhalf1 = new byte[16];
            var encryptedhalf2 = new byte[16];

#if USEBC || WINDOWS_UWP
            var aes = BitcoinEncryptedSecret.CreateAES256(true, derivedhalf2);
#else
            var aes = CreateAES256();
            aes.Key = derivedhalf2;
            var encrypt = aes.CreateEncryptor();
#endif

            for (int i = 0; i < 16; i++)
            {
                derivedhalf1[i] = (byte)(keyhalf1[i] ^ derivedhalf1[i]);
            }
#if USEBC || WINDOWS_UWP
            aes.ProcessBytes(derivedhalf1, 0, 16, encryptedhalf1, 0);
            aes.ProcessBytes(derivedhalf1, 0, 16, encryptedhalf1, 0);
#else
            encrypt.TransformBlock(derivedhalf1, 0, 16, encryptedhalf1, 0);
#endif
            for (int i = 0; i < 16; i++)
            {
                derivedhalf1[16 + i] = (byte)(keyhalf2[i] ^ derivedhalf1[16 + i]);
            }
#if USEBC || WINDOWS_UWP
            aes.ProcessBytes(derivedhalf1, 16, 16, encryptedhalf2, 0);
            aes.ProcessBytes(derivedhalf1, 16, 16, encryptedhalf2, 0);
#else
            encrypt.TransformBlock(derivedhalf1, 16, 16, encryptedhalf2, 0);
#endif
            return(encryptedhalf1.Concat(encryptedhalf2).ToArray());
        }