This is a simple Python tool that helps you check your code files for things that might look like API keys. It looks for long strings of letters and numbers, which are common in API keys.
Important: This tool is designed to help you find potential keys in your own files before you share them. It does not search the internet or other people's code.
- Save the script: Save the Python code (the one we created earlier,
key_checker.py) to your computer. - Open your command line (or terminal):
- Windows: Search for "cmd" in the Start Menu.
- macOS: Open the "Terminal" application (in Applications > Utilities).
- Go to the folder: Use the
cdcommand to navigate to the folder where you savedkey_checker.py. For example, if it's in your "Downloads" folder, typecd Downloadsand press Enter. - Run the script: Type
python key_checker.pyand press Enter. - Enter the file path: The tool will ask you to type the location (path) of the file you want to check. For example, if you want to check a file called
my_project.pyin the same folder, just typemy_project.pyand press Enter. If it's somewhere else, you'll need to type the full path (likeC:\Users\YourName\Documents\my_project\my_project.pyon Windows or/Users/YourName/Documents/my_project/my_project.pyon macOS).
The script will read through the file you choose and look for lines that contain long sequences of letters and numbers. If it finds any, it will show you the line number and the line itself.
- It might not be perfect: This tool looks for patterns and might sometimes highlight things that aren't actually API keys.
- You need to double-check: Always look at the lines the tool shows you and decide if they really contain a private key that you shouldn't share.
- It only checks the file you tell it to: It doesn't search your whole computer or the internet.
If you have ideas on how to make this tool better, you're welcome to share them! Maybe you have suggestions for better patterns to look for.
This is a simple tool and doesn't have a formal license right now. Feel free to use it and share it!