Ejemplo 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,
            });
        }
Ejemplo 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));
        }