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

Use PGP/GnuPG for encryption [enhancement] #334

Closed
jd666 opened this Issue Sep 26, 2016 · 9 comments

Comments

Projects
None yet
3 participants
@jd666

jd666 commented Sep 26, 2016

The example below is using gpg with symmetric encryption - being able to encrypt with public/private keys would be beneficial as well.

$ cat Lorem\ Ipsum.md
Lorem Ipsum
========================

"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."

"There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain..."

---

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur placerat lorem non metus interdum aliquet. Maecenas ligula velit, pharetra vel mauris et, tristique accumsan quam. Praesent sed varius nisi. Mauris scelerisque tellus vitae ullamcorper dapibus. Quisque lacinia porttitor felis eget gravida. Praesent in eros ornare, mattis diam a, mattis sapien. Aenean in dolor risus. Donec vehicula sodales erat, vitae pretium ipsum pretium eget.

Vestibulum congue leo vehicula nibh porta, ac dapibus diam mattis. Sed in varius ex. Mauris interdum sem in dictum consequat. Nullam ut nibh at urna auctor volutpat id eget nisi. Vestibulum viverra enim nec mattis porta. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque euismod lectus leo, ut aliquet augue suscipit nec. Curabitur hendrerit felis a mi malesuada consectetur. Quisque gravida arcu nec egestas convallis. Pellentesque suscipit sapien ut tortor gravida egestas. Praesent ac consectetur ante. Proin dictum lectus a facilisis consectetur. Curabitur scelerisque feugiat dolor, et maximus ante ullamcorper eget.

Praesent eget urna purus. Proin sapien erat, finibus id aliquet eleifend, elementum et sapien. Sed tincidunt nisl sollicitudin, iaculis eros id, suscipit odio. In massa mi, eleifend a nisi nec, vehicula dapibus risus. Mauris convallis, diam eu efficitur auctor, ex est suscipit velit, nec suscipit diam tellus ac erat. Mauris ullamcorper, nibh quis dictum rutrum, tellus velit euismod ipsum, nec posuere orci diam pellentesque nulla. Duis dapibus porta sapien eget pulvinar. Mauris hendrerit ipsum in odio dictum lacinia. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse sit amet dolor purus. Pellentesque eu metus sodales, bibendum odio non, laoreet mi.

Vivamus mattis tincidunt mauris non dapibus. Duis pretium pulvinar ultrices. Phasellus ornare finibus neque, non porttitor ex faucibus quis. Vestibulum ornare magna sit amet enim vestibulum pulvinar. Vestibulum risus arcu, varius non vulputate condimentum, mattis in enim. Nam tincidunt nisi ac ornare auctor. Suspendisse accumsan hendrerit massa, vel venenatis nisi fringilla eget. Pellentesque ut ante lectus. In hac habitasse platea dictumst. Fusce venenatis ipsum est. Praesent blandit mauris leo, at vehicula mauris gravida in. Vestibulum in gravida mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam commodo elit blandit ligula tempor tempor. Suspendisse eu porttitor mi, vel ultrices sapien.

Mauris elit justo, dapibus nec commodo id, gravida id augue. Etiam turpis lacus, ultricies sed orci ut, placerat pulvinar elit. Proin dignissim non lorem sit amet dapibus. Sed est nulla, sagittis ac dui vitae, aliquam eleifend magna. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ultrices finibus scelerisque. Pellentesque faucibus id felis eget hendrerit. Aenean non purus posuere, blandit nisi quis, sagittis massa. Quisque et ipsum eu tortor commodo ultricies id sit amet justo. Praesent orci risus, congue ac suscipit ac, lobortis vel urna. Aenean mi quam, hendrerit vel justo vitae, commodo ultricies leo. Maecenas velit magna, commodo id odio et, aliquet molestie quam. Proin non ante metus. Donec mattis accumsan dignissim. Donec sem mi, rhoncus elementum fringilla sed, varius at elit. Nulla at tristique risus, dignissim egestas mauris.

Generated 5 paragraphs, 500 words, 3433 bytes of [Lorem Ipsum](http://www.lipsum.com/)

---

help@lipsum.com
$ ( head -3 Lorem\ Ipsum.md; tail -n +4 Lorem\ Ipsum.md | gpg -ac; ) > Lorem\ Ipsum\ encrypted.md 
$ ( head -3 Lorem\ Ipsum\ encrypted.md; gpg < Lorem\ Ipsum\ encrypted.md; ) > Lorem\ Ipsum\ unencrypted.md 
gpg: AES encrypted data
gpg: encrypted with 1 passphrase
$ ls -al
total 24
drwxr-xr-x   5 me  staff   170 26 Sep 13:47 ./
drwxr-xr-x  93 me  staff  3162 26 Sep 13:29 ../
-rw-r--r--   1 me  staff  2293 26 Sep 13:33 Lorem Ipsum encrypted.md
-rw-r--r--   1 me  staff  3805 26 Sep 13:47 Lorem Ipsum unencrypted.md
-rw-r--r--   1 me  staff  3805 26 Sep 13:28 Lorem Ipsum.md
$ diff Lorem\ Ipsum.md Lorem\ Ipsum\ unencrypted.md 
$ cat Lorem\ Ipsum\ encrypted.md
Lorem Ipsum
========================

-----BEGIN PGP MESSAGE-----

jA0EBwMC7ugv1VqBqwpg0uoBrN8E9Ib8JduH7aIMAAi9ykmAofHCokVydkCyA49n
7kxjd4gi9aNtm+5WLDORmqmIpDczjEkG2cXL9HNpXj8RKpZ3fG0HUxJYbdGOf0Y7
i/rfUwUgeiCVl+sTKwJ6qh7K0EVaBKsM7UeV13ZtjZAz3niOIU4JTsovGg1eo+3X
b1ZltH3iLfPGY5VcV75M0G2u37gqb/wHq0dWnr+v2sa4ocLSAcTm63lnvcdeKCYO
2/B1NBTkRBSwXdhy7cKIlU6lpgUpuKuQ5NVx7OVcKGbEEm2hIVSVlhADWliRAoEb
6faGppGSiBejKNOoGNhy/363VC0O1JAu6vfFDOV5ihMBCcKwX46JXh3VRy9uT9vD
cvP98ELKXCV/3enrchJIJlOfyNDzv90k8fRHf9XKIJVlmsNPGf61fza57jFhqdY+
IcDgTRMk8fGmrHsGk0ed+o8y8AeN/HnPfrzJN9CcLMRRbSAIcgV+/DDZPyW4k1Vn
Ig1FwOXv/+yThnFd7yz2tolEOCpjMABqXjfI7Toby2T8wqK5Uj2jrEPcV0nXyAHb
rowGYiSV9ZEVzHRS+tRHFa4eJNL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gs3Q10s
dEqmkvWLK3tsF6PzfW9zp+BJxEhImG5etqJuCHn5cJ9J+0bgWJ6m5AX82VaNKYAv
OeHx7G9UmWhj53VOuEDez7rDcdXC4wmLkdMy5fqos7z/np6lk6VDNxKmh9gwLTiJ
KU7unTHeKUlB2LghTzAJOz3ZFP/pBxKA44T2B0Gy1gV5+/aJP2idcKcoPnmDrcba
EyuBGfNOn9A+T2T+nuXNZjuaGQwjeTXkxE9qIukhE9Xh6wOQlfYf9coNH5pH5CXU
o3CTe6DyB+ro8msD8E8b1yj5ULHl6oVcCmeBp0ZKFK6pt/lTCg3mcY+PVPLE6Dss
Nux8K31FdrcZYtIb4ZSuzXLAbN0Wqx/oFYPRj9goN/T3l5a+PKZlgmFOci2w+4ng
f6C+aU6V4Hu/CyI5pRp0b/sZQExz0inEiSE0/hk943+NUDnocp3bBvAPd1iU/pnR
lT6e+X5DxsRHJvvavB6EDf8vU0savHwqaX+dFlFOmnVV3e4=
=7Sfa
-----END PGP MESSAGE-----

@pbek pbek added the enhancement label Sep 26, 2016

@pbek

This comment has been minimized.

Owner

pbek commented Sep 26, 2016

Thank you for your suggestion. I've kind of that thing already on my todo list.
I planed to make the commands to encrypt and decrypt notes configurable via the scripting engine.
And what that command returns will be placed inside the ENCRYPTED TEXT block.

<!-- BEGIN ENCRYPTED TEXT --
whatever the script command returns
-- END ENCRYPTED TEXT -->

This way everyone could use what they like to encrypt and decrypt notes.
Any objections?

@ghost

This comment has been minimized.

ghost commented Sep 28, 2016

Nice, Via Scripting will be nice. I already encrypt my passwords with passwordstore.. (same basic concept different application)

@pbek

This comment has been minimized.

Owner

pbek commented Sep 28, 2016

Completely independ encryption and decryption via selecting text is now possible (although there is yet no integration with the integrated encryption system of QOwnNotes).

16.09.17

  • there a now is a new scripting method script.noteTextEditWrite(text)
    to write text to the note text edit
  • there a now is a new scripting method script.noteTextEditSelectedText()
    to read the selected text from the note text edit
@pbek

This comment has been minimized.

Owner

pbek commented Sep 28, 2016

There now is a new release, could you please test it and report if the new features work for you (if you are using the new scripting methods)?

@pbek pbek added this to the 16.10.0 milestone Oct 2, 2016

@pbek

This comment has been minimized.

Owner

pbek commented Oct 2, 2016

16.10.0

  • you now can use your custom method to encrypt and decrypt notes
    • you can use the new scripting hook encryptionHook() do implement
      your own encryption
    • there are examples to encrypt notes with Keybase.io
      (encryption-keybase.qml),
      PGP (encryption-pgp.qml) or
      do a trivial "encryption" with ROT13
      (encryption-rot13.qml)
    • you can disable the password dialog with script.encryptionDisablePassword()
    • to start an external synchronous process you can use script.startSynchronousProcess()
    • to check on which platform the script is running there is
      script.platformIsLinux(), script.platformIsOSX() and script.platformIsWindows()
    • for more information on the new commands please take a look at the
      scripting documentation

@jd666, you will have to play around with https://github.com/pbek/QOwnNotes/blob/develop/doc/scripting/encryption-pgp.qml to get going, please let me know how it worked out. There also is an other example https://github.com/pbek/QOwnNotes/blob/develop/doc/scripting/encryption-keybase.qml that I am using to encrypt note with Keybase.io, that uses PGP too.

@pbek

This comment has been minimized.

Owner

pbek commented Oct 2, 2016

@jd666, @MBuchaus
There now is a new release, could you please test it and report if the new features work for you?

@jd666, I already sent you a keybase.io invite back a while, in case you want to use it.

@pbek

This comment has been minimized.

Owner

pbek commented Oct 2, 2016

@Maboroshy, are you using encryption by chance?

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Oct 2, 2016

Not in the app, sorry.

@pbek

This comment has been minimized.

Owner

pbek commented Oct 2, 2016

@Maboroshy Oh, we found something you are not using in QOwnNotes! :)

In case you want to call external processes in scripts and use the output in QOwnNotes: script.startSynchronousProcess() is your new friend ;)

@pbek pbek closed this Oct 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment