Coding Question
Created by: tigergroup
I have been working on this for over a day and seem to not get this working correctly. I have a json that I parsed. I need to take the current password in the json, encrypted it and put it back in the json.
json:
{ "wifi": { "ssid": "somessid", "password": "somepassword" }, }
convert to:
{ "wifi": { "ssid": "somessid", "password": "AGjsdfDv4Sf3f" }, }
I tried something like this:
StaticJsonBuffer<MAX_JSON_CONFIG_ARDUINOJSON_BUFFER_SIZE> jsonBuffer;
JsonObject& parsedJson = jsonBuffer.parseObject(buf);
if (!parsedJson.success()) {
this->_interface->logger->logln(F("
JsonObject& jsonWifi = parsedJson["wifi"];
int strLength = strlen(jsonWifi["password"]);
char unencryptedPassword[strLength];
strcpy(unencryptedPassword, jsonWifi["password"]);
char encryptedWifiPasswordEncoded[MAX_WIFI_PASSWORD_LENGTH];
_encryptPassword(encryptedWifiPasswordEncoded, (byte*)unencryptedPassword, strlen(unencryptedPassword));
jsonWifi.set("password",encryptedWifiPasswordEncoded);
Can anyone guide me on what I am doing wrong?
scott