EddyVerbruggen / nativescript-secure-storage

:closed_lock_with_key: NativeScript plugin for secure local storage of fi. passwords
MIT License
111 stars 26 forks source link

.getSync() occasionally returns "ée" instead of what was saved #36

Closed WrightTrae closed 4 years ago

WrightTrae commented 4 years ago

This only happens occasionally other times the correct data is returned. I am using version 2.6.0 Nativescript version: 6.1.2

This is how I am saving the data

    let data = JSON.stringify({
      mfaCode: '',
      username: '',
      password: ''
    })
    this.secureStorage.setSync({
      key: "login",
      value: btoa(data)
    });

This is how I am reading the data

      this.savedUserCred = this.secureStorage.getSync({ key: "login" });
      console.log(atob(this.savedUserCred)); // Outputs "ée"

Does it this issue having something to do with me saving the data as base64?

EddyVerbruggen commented 4 years ago

Probably yeah. Simply try without encoding in a different property to check that. And why do you btoa it in the first place?

WrightTrae commented 4 years ago

Yeah, that was the issue. Honestly, I'm not sure why the original developer did it that way. I figured it had something to do with the limitation of this plugin at the time he wrote it. Thanks!!