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, }); }
public static byte[] DecodePayload(Payload payload, string secret) { var keyBytes = KeyDerivedBytes.GetBytes(secret, AesEncryptor.KeySize); return(AesEncryptor.Decrypt(payload.EncryptedData, keyBytes, payload.Vector)); }