It is not secure. David Leadbeater posted POC code to brute-force upto 64 bytes in an article titled, somewhat ironically, Vim blowfish encryption... or why you shouldn't roll your own crypto. The Vim documentation now recommends:
- The implementation of 'cryptmethod' "blowfish" has a flaw. It is possible
to crack the first 64 bytes of a file and in some circumstances more of the
file. Use of it is not recommended, but it's still the strongest method
supported by Vim 7.3 and 7.4. The "zip" method is even weaker.
And, earlier on:
The text in the swap file and the undo file is also encrypted. E843
However, this is done block-by-block and may reduce the time needed to crack a
password. You can disable the swap file, but then a crash will cause you to
lose your work. The undo file can be disabled without much disadvantage.
:set noundofile
:noswapfile edit secrets
Note: The text in memory is not encrypted. A system administrator may be able
to see your text while you are editing it. When filtering text with
":!filter" or using ":w !command" the text is also not encrypted, this may
reveal it to others. The 'viminfo' file is not encrypted.
Summary:
- If you care about security,
blowfish
should not be used. Use blowfish2
or xchacha20
instead. xchacha20 requires that Vim was built with +sodium, but is the most secure option as it uses the well-known libsodium.
- While
swap
and undo
files are encrypted, viminfo
isn't.
Unsolicited advice:
- If you do care about security, do not roll your own encryption. And that means the
blowfish2
implementation as well. Use something else, like GPG. The gnupg.vim
plugin may be useful. It seems to be maintained. It disables viminfo
and the swap file.
:h encryption
says undo and swap files are encrypted in both 7.3 and 7.4, yet:h cryptmethod
in 7.4 makes explicit mention of theundo
file only forblowfish2
.