Search code examples
angularcryptographynativescriptlibsodium

How to share my private key Nativescript simple libsodium


I'm starting a nativescript project with Simple libsodium NativeScript plugin, but I am not sure how to reconstruct my public key once I shared it as string. I'm doing this:

 KeyToString(){

  let my = this.simpleLibsodium.boxKeyPaired();

  // Convert publicKey in to string
  let stringBase64 = this.simpleLibsodium.bytesToBase64(my.public_key) // "ABDCDFDAB2ABD2BBACDFDC"

  // Here there is not problem!!!
  return stringBase64

}


StringToKey(base64String){

  // I WANT TO CONVERT FROM BASE64 STRING TO PUBLIC KEY AGAIN
  ???
}

I'm not sure that this is even possible, but if it is I will appreciate any help since this plugin documentation is very limited and the original libsodium docs does not translate quite well to this library.


Solution

  • After some try i realized i was doing something really dumb, i only was converting the public key to string when you need both keys to decrytp the message usin crypto_box_easy()

    Thanks