Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add md5 hash to resource, to be used for fix_attachment_reference #54

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions evernote_backup/note_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import re
import uuid
import hashlib
import binascii
from typing import Optional

import xmltodict
Expand Down Expand Up @@ -66,9 +68,14 @@ def format_note(self, note: Note) -> str:
return str(note_template)

def _fmt_resource(self, resource: Resource) -> dict:
# Create MD5 hash
md5 = hashlib.md5()
md5.update(resource.data.body)
md5_hash = binascii.hexlify(md5.digest()).decode()
return {
"data": {
"@encoding": "base64",
"@hash": md5_hash,
"#text": self._fmt_raw(fmt_binary(resource.data.body)),
},
"mime": resource.mime,
Expand Down
Loading