title: How to prevent WiFi Password from being leaked from Lua code?
body: <p>I have a Lua program which connects to a wifi network. The wifi password is hardcoded in the Lua code. I put the Lua code on an ESP8266 which runs on the NodeMCU firmware.</p>
  
  <p><a href="https://i.stack.imgur.com/BblId.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BblId.jpg" alt="enter image description here"></a>  </p>
  
  <p>Here is the code I use: </p>
  
  <pre><code>wifi.setmode(wifi.STATION)
  wifi.sta.config("SSID", "password")
  wifi.sta.connect()
  
  srv = net.createServer(net.TCP)
  srv:listen(80,function(conn)
      conn:on("receive", function(conn, payload)
          print(payload)
          local response = "HTTP/1.1 200 OK\r\n\r\n&lt;h1&gt; Hello, NodeMcu.&lt;/h1&gt;"
          conn:send(response, function()
              conn:close()
          end)
      end)
  end)
  </code></pre>
  
  <p>When I use this setup for outdoor sensors anyone can grab the ESP8266, read the Lua script and get my WiFi password. </p>
  
  <ol>
  <li>Is there somewhere to encrypt the password on the ESP8266 with Lua? </li>
  <li>Is is possible to use some external crypto unit? </li>
  <li>Does compiled Lua code changes anything? </li>
  </ol>