/// <summary> /// Encrypts the message. Implements <see cref="IAESService.Encrypt(dynamic)"/>. /// </summary> /// <param name="json">The JSON object to be encrypted.</param> /// <returns>The cipherbytes.</returns> public byte[] Encrypt(dynamic json) { helperAES = new AESHelper(); byte[] message = helperAES.Normalize(json); algorithm = new Grasshopper(); using (MemoryStream stream = new MemoryStream(message)) { byte[] block = new byte[16]; byte[] cipherbytes = new byte[0]; while (stream.Read(block, 0, blockLength) > 0) { Array.Resize(ref cipherbytes, cipherbytes.Length + blockLength); Array.Copy(algorithm.Encrypt(block, Keys.GrasshopperKey), 0, cipherbytes, cipherbytes.Length - blockLength, blockLength); } return(cipherbytes); } }