Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #351
Closed
Open
Issue created Sep 09, 2016 by Administrator@rootContributor

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("✖ Invalid JSON in the config string")); return; }

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

Assignee
Assign to
Time tracking