Coder Social home page Coder Social logo

Comments (10)

simc avatar simc commented on June 23, 2024

Hi,
Do want to backup a box or do you want to decrypt and use the data on the server?

Every encrypted entry also contains an IV without that, the entry cannot be decrypted.

What would putRaw() and getRaw() do exactly? And what would getRaw() return for other objects?

from hive.

leedstyh avatar leedstyh commented on June 23, 2024

Hi,

I wanna backup the whole box, incrementally. Say I have 10 items total in the box now, after changing one item (box.put('myDog', dog)), I sync it to the server right away. Or one item changed on the server, I need to sync the changed one to the client app.

I wanna encrypt the user data both on client app and server, and since Hive already encrypt data, I think reuse it is a good idea.

So what transferred between client app and server is NOT dog, but the dog after encrypted. I'm not sure but I assume it's a String("xxxooo") stored on the storage after dog encrypted.

Future<String> box.getRaw("myDog") returns that String("xxxooo") and I sync this String("xxxooo") to the server.

Future<void> putRaw("myDog", "xxxooo from server") save the change from the server directly.

Sorry that I'm not good at English.

from hive.

simc avatar simc commented on June 23, 2024

Okay I understand... The problem is that Hive stores objects as Uint8List when running in the vm. In the browser, only non primitive and encrypted values are stored as Uint8List. I don't know what getRaw() should return. A string is impossible because of the IV.

I think the best way is to transfer the data unencrypted over HTTPS and handle encryption on the server (maybe even with another Hive ;).

You would have to sync the value, the IV and the encryption key otherwise.

Edit: You can implement your sync logic using watch()

from hive.

leedstyh avatar leedstyh commented on June 23, 2024

I got it. But encrypt and decrypt both on client and server will waste too much CPU :(

I can encrypt the data to a string by myself, and save this string in hive(box.put("myDog", "encrypted string")). And I register a TypeAdapter say LongString for it in case the encrypted string is too long.

Do you think it is a good idea?

from hive.

simc avatar simc commented on June 23, 2024

Sure you can do that but unless you change the data very often I would not worry about CPU usage. The AES algorithm Hive uses is quite fast.

from hive.

leedstyh avatar leedstyh commented on June 23, 2024

Thanks @leisim I'll double think how to design my app

from hive.

ThinkDigitalSoftware avatar ThinkDigitalSoftware commented on June 23, 2024

Won't transferring it unencrypted leave you vulnerable for mitm attacks?

from hive.

adriancmurray avatar adriancmurray commented on June 23, 2024

@ThinkDigitalSoftware this is why @leisim specified transferring over HTTPS to encrypt over the channels. The encryption here is so those who have direct access to the data can not read it (such as us developers) unless trusted.

from hive.

ThinkDigitalSoftware avatar ThinkDigitalSoftware commented on June 23, 2024

Oh that makes sense.

from hive.

jamesdixon avatar jamesdixon commented on June 23, 2024

@adriancmurray what approach did you end up taking? looking to rebuild my app and it definitely needs to be offline-first so im exploring options for persistence, including hive.

from hive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.