I want to build a webapp and a sister mobile app (using react native) that uses client side encryption. The encryption would be for text entries written on a daily basis that the user could create and edit. If the user goes offline, I want them to still be able to edit entries currently on their device and to create new entries, and I want those edits to be pushed to the server when the user comes back online.
If the user enters text offline for a particular day on one device, then forgets and enters different text offline on another device for the same day, I'd like the two entries to be merged into one entry when the devices go back online. Is there any sort of magic that would allow me to do that on the server with the encrypted files?
If not, I'd have the devices send a hash of the encrypted text as it was before the edits. When the updated text hits the server, I would send the hash along and compare it to the hash of the encrypted text that was currently stored. When the second update comes, the hash would not match the stored text, and the stored text would be sent back to the client to be reconciled. Are there existing protocols/libraries out there for this sort of thing? I'd rather not reinvent the wheel.