0Pricing
Arduino & IoT Academy · Lekcja

Usuwanie sekretów z kodu

Bezpiecznie przechowywać dane uwierzytelniające, a nie w postaci jawnego tekstu.

Usuwanie sekretów z kodu to bezpłatna lekcja Arduino & IoT Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Arduino & IoT Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

What Counts as a Secret

WiFi passwords, API tokens, and private keys are all secrets. Anything that grants access must never sit in plain sight inside your sketch. 🔑

The Danger of Plaintext Keys

Flash memory can be read back over the wire. A plaintext key in your code is one chip dump away from being copied by anyone.

String apiKey = "AKIA12345SECRET"; // visible to anyone who reads the flash

Why Git Makes It Worse

Commit a secret once and it lives in your history forever. Even after you delete it, the old commit still holds the exposed key.

Use a Separate Header

Put credentials in a small file like secrets.h kept out of version control. This secrets header keeps keys off GitHub while your sketch stays shareable.

#include "secrets.h" // holds WIFI_SSID and WIFI_PASS, never committed

Ignore It in Git

Add your secrets file to .gitignore so it can never be committed by accident. This single line prevents most real-world key leaks.

# .gitignore
secrets.h

Provision at Setup Time

Instead of baking keys in, enter them once when the device first boots. Provisioning via a config page keeps secrets off your source entirely.

Store in NVS or EEPROM

The ESP32 offers NVS, a key-value store in flash for runtime secrets. You write the token once and read it back on every boot.

preferences.begin("net", false);
preferences.putString("token", userToken);

One Device, One Key

Give each unit its own credentials, never a shared master key. With per-device keys, one stolen device can be revoked without touching the rest.

Rotate and Revoke

Plan to change keys on a schedule and kill leaked ones fast. Rotation limits how long any single stolen secret stays useful.

Least Privilege

Give each token only the access it truly needs. Least privilege means a leaked device key can read its own topic, not your whole account.

Scan Before You Push

Tools can catch a key before it reaches a remote repo. A secret scanner in your workflow blocks accidental leaks before they happen.

Quick Check

One of these keeps a key off your public repo.

Recap

Never bake secrets into code. Use a gitignored header, provision at setup, store in NVS, and keep per-device keys you can rotate. 🔐

Często zadawane pytania

Czy lekcja „Usuwanie sekretów z kodu” jest bezpłatna?

Tak — pełny tekst „Usuwanie sekretów z kodu” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Arduino & IoT Academy, przejdź na CoddyKit PRO. Kurs Arduino & IoT Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Usuwanie sekretów z kodu”?

Bezpiecznie przechowywać dane uwierzytelniające, a nie w postaci jawnego tekstu. Ćwiczysz Arduino & IoT Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Arduino & IoT Academy?

Nie wymagamy żadnego doświadczenia. Arduino & IoT Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.

Ile czasu zajmuje lekcja „Usuwanie sekretów z kodu”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Arduino & IoT Academy?

Tak. Każda lekcja Arduino & IoT Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Typowe powierzchnie ataku IoT
  2. Usuwanie sekretów z kodu
  3. Szyfrowanie TLS i weryfikacja certyfikatów
  4. Podpisywanie i zabezpieczanie firmware'u
← Powrót do Arduino & IoT Academy