add encryption function when transmitting messages