Esempio n. 1
0
        public static Payload CreatePayload(byte[] rawBytes, string secret)
        {
            var keyBytes         = KeyDerivedBytes.GetBytes(secret, AesEncryptor.KeySize);
            var encryptedCommand = AesEncryptor.Encrypt(rawBytes, keyBytes, out byte[] vector);

            return(new Payload()
            {
                Vector = vector,
                EncryptedData = encryptedCommand,
            });
        }
Esempio n. 2
0
        public static byte[] DecodePayload(Payload payload, string secret)
        {
            var keyBytes = KeyDerivedBytes.GetBytes(secret, AesEncryptor.KeySize);

            return(AesEncryptor.Decrypt(payload.EncryptedData, keyBytes, payload.Vector));
        }