improvements in encryption function and keys