second attempt at adding encryption support