included authentication functions for writing encrypted file