mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-18 03:58:32 +02:00
Merge 362107f853
into 9ffca1a7a6
This commit is contained in:
commit
fbfda8d6dd
3 changed files with 21 additions and 3 deletions
|
@ -16,6 +16,8 @@
|
||||||
Scenario: Encrypting a journal
|
Scenario: Encrypting a journal
|
||||||
Given we use the config "basic.json"
|
Given we use the config "basic.json"
|
||||||
When we run "jrnl --encrypt" and enter "swordfish"
|
When we run "jrnl --encrypt" and enter "swordfish"
|
||||||
|
Then we should see the message "Confirm Password:"
|
||||||
|
When we enter "swordfish"
|
||||||
Then we should see the message "Journal encrypted"
|
Then we should see the message "Journal encrypted"
|
||||||
and the config for journal "default" should have "encrypt" set to "bool:True"
|
and the config for journal "default" should have "encrypt" set to "bool:True"
|
||||||
When we run "jrnl -n 1" and enter "swordfish"
|
When we run "jrnl -n 1" and enter "swordfish"
|
||||||
|
@ -30,7 +32,9 @@
|
||||||
Scenario: Storing a password in Keychain
|
Scenario: Storing a password in Keychain
|
||||||
Given we use the config "multiple.json"
|
Given we use the config "multiple.json"
|
||||||
When we run "jrnl simple --encrypt" and enter "sabertooth"
|
When we run "jrnl simple --encrypt" and enter "sabertooth"
|
||||||
When we set the keychain password of "simple" to "sabertooth"
|
Then we should see the message "Confirm Password:"
|
||||||
|
When we enter "sabertooth"
|
||||||
|
and we set the keychain password of "simple" to "sabertooth"
|
||||||
Then the config for journal "simple" should have "encrypt" set to "bool:True"
|
Then the config for journal "simple" should have "encrypt" set to "bool:True"
|
||||||
When we run "jrnl simple -n 1"
|
When we run "jrnl simple -n 1"
|
||||||
Then we should not see the message "Password"
|
Then we should not see the message "Password"
|
||||||
|
|
|
@ -73,7 +73,14 @@ def guess_mode(args, config):
|
||||||
|
|
||||||
def encrypt(journal, filename=None):
|
def encrypt(journal, filename=None):
|
||||||
""" Encrypt into new file. If filename is not set, we encrypt the journal file itself. """
|
""" Encrypt into new file. If filename is not set, we encrypt the journal file itself. """
|
||||||
password = util.getpass("Enter new password: ")
|
confirmed_password = False
|
||||||
|
while confirmed_password == False:
|
||||||
|
password = util.getpass("Enter new password: ")
|
||||||
|
password_conf = util.getpass("Confirm password: ")
|
||||||
|
if password == password_conf:
|
||||||
|
confirmed_password = True
|
||||||
|
else:
|
||||||
|
print("Password and confirmation did not match, try again.")
|
||||||
journal.make_key(password)
|
journal.make_key(password)
|
||||||
journal.config['encrypt'] = True
|
journal.config['encrypt'] = True
|
||||||
journal.write(filename)
|
journal.write(filename)
|
||||||
|
|
|
@ -69,7 +69,14 @@ def install_jrnl(config_path='~/.jrnl_config'):
|
||||||
|
|
||||||
# Encrypt it?
|
# Encrypt it?
|
||||||
if module_exists("Crypto"):
|
if module_exists("Crypto"):
|
||||||
password = getpass.getpass("Enter password for journal (leave blank for no encryption): ")
|
confirmed_password = False
|
||||||
|
while confirmed_password == False:
|
||||||
|
password = getpass.getpass("Enter password for journal (leave blank for no encryption): ")
|
||||||
|
password_conf = getpass.getpass("Confirm password: ")
|
||||||
|
if password == password_conf:
|
||||||
|
confirmed_password = True
|
||||||
|
else:
|
||||||
|
print("Password and confirmation did not match, try again.")
|
||||||
if password:
|
if password:
|
||||||
default_config['encrypt'] = True
|
default_config['encrypt'] = True
|
||||||
if util.yesno("Do you want to store the password in your keychain?", default=True):
|
if util.yesno("Do you want to store the password in your keychain?", default=True):
|
||||||
|
|
Loading…
Add table
Reference in a new issue