Avoiding secret key encryption error