Card: Fix the process of writing key or generating key.