use of com.owncloud.android.datamodel.EncryptedFolderMetadata in project android by nextcloud.
the class EncryptionTestIT method encryptionMetadata.
/**
* DecryptedFolderMetadata -> EncryptedFolderMetadata -> JSON -> encrypt
* -> decrypt -> JSON -> EncryptedFolderMetadata -> DecryptedFolderMetadata
*/
@Test
public void encryptionMetadata() throws Exception {
DecryptedFolderMetadata decryptedFolderMetadata1 = generateFolderMetadata();
// encrypt
EncryptedFolderMetadata encryptedFolderMetadata1 = EncryptionUtils.encryptFolderMetadata(decryptedFolderMetadata1, privateKey);
// serialize
String encryptedJson = EncryptionUtils.serializeJSON(encryptedFolderMetadata1);
// de-serialize
EncryptedFolderMetadata encryptedFolderMetadata2 = EncryptionUtils.deserializeJSON(encryptedJson, new TypeToken<EncryptedFolderMetadata>() {
});
// decrypt
DecryptedFolderMetadata decryptedFolderMetadata2 = EncryptionUtils.decryptFolderMetaData(encryptedFolderMetadata2, privateKey);
// compare
assertTrue(compareJsonStrings(EncryptionUtils.serializeJSON(decryptedFolderMetadata1), EncryptionUtils.serializeJSON(decryptedFolderMetadata2)));
}
Aggregations