Modified crypto key generation to avoid errors