Monday, January 13, 2020

Re: -x option encryption

On 2020-01-13 11:16, 'Grant Taylor' via vim_use wrote:
> On 1/13/20 10:22 AM, 'Andy Wokula' via vim_use wrote:
> > You can set a key with :set key=mycoolkey
>
> Interesting.
>
> > This works here (doubles quotes = on Windows):
> >
> > vim --cmd "set key=mycoolkey" mynicefile.txt
>
> I wonder if it would be possible to play with other methods to
> populate the "mycoolkey" text. Admittedly, they aren't as Windows
> friendly.
>
> Environment variables are the first thing that comes to mind.

Did a quick test:

$ vim delme.txt
[add some text]
:set key=secret
:wq
$ KEY="$(echo secret)" vim +'let &key=$KEY | e delme.txt

which lets you use any method you want to obtain the secret key
(using the super-secure "echo" method of password storage here)

Alternatively, you could obtain the key without the environment
variable, though note that the trailing newline becomes part of the
password:

$ echo secret > password.txt
$ vim delme.txt
[add some text]
:let &key=system('cat password.txt")
:wq
$ vim +'let &key=system("cat password.txt") | e delme.txt'

where you can use whatever program you want in place of

"cat password.txt"

to obtain your password.

-tim






--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200113124530.5704d98f%40bigbox.attlocal.net.

No comments: