implement encrypt() function