Connect with us

Do not pass on Wifi credentials accidentally

Discussion in 'Microcontrollers, Programming and IoT' started by Harald Kapp, Nov 16, 2020.

Scroll to continue with content
  1. Harald Kapp

    Harald Kapp Moderator Moderator

    10,591
    2,360
    Nov 17, 2011
    When programming for WIFI access, many (if not most) code examples will have these 2 lines (or equivalent ones) at the beginning of the code:
    Code:
    const char* ssid = "yourNetworkName";
    const char* password = "yourNetworkPassword";
    You replace "yourNetworkName" and "yourNetworkPassword" by the network credentials of the Wifi network where the device is going to be used, usually your own Wifi network.
    That is all good as long as the code doesn't leave your PC. However, you may happen to publish your code, be it on Github or simply as part of a request e.g. on this forum. If you forget to reset the Wifi credentials to a neutral value as in the above example, your network is compromised.

    I suggest to replace the 2 lines by an include:
    Code:
    #include "/localdirectory/myWifiCredentials.h";
    or the equivalent if using another programming language.
    This local file contains the above 2 lines with your credentials only. When you publish your code, the include will not work on anybody else's computer until he/she creates his/her own local credential file. Your own credentials never leave your computer.

    Cheers,
    Harald Kapp
     
    bertus, Martaine2005 and kpatz like this.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-