I know using :set cryptmethod=zip is not secure, but how secure is using :set cryptmethod=blowfish?

On wikipedia I read that the blowfish cipher, as such, should be secure, but this says nothing about the security of Vim's implementation of it.

And what about swapfiles, backupfiles, undofiles, and other possible ways to bypass the blowfish encryption? How secure is Vim there?

  • 1
    Won't this really be better off at Information Security, given that you have already identified the algorithm(s) being used?
    – muru
    Feb 4, 2015 at 22:49
  • Hmm. The docs are a bit confusing here. :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 the undo file only for blowfish2.
    – muru
    Feb 4, 2015 at 23:00
  • 3
    @muru It's a question about Vim's implementation of blowfish-based encryption, not about the blowfish algorithm itself. This question would also be on-topic on Information Security, but that doesn't make it off-topic here. The answer is, in fact, that blowfish itself is secure (even if it isn't the best choice), but that Vim's implementation of it is bad. Feb 5, 2015 at 0:17

1 Answer 1


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.


  • 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.
  • 1
    The claim by David Leadbeater in (dgl.cx/2014/10/vim-blowfish) the last para is using a dictionary for bruteforce attack. He then adds "small passwords" would weak. His theoretical arguments are correct but not practical. Good 64 bit or more random passwords are uncrackable.
    – mosh
    Aug 30, 2016 at 16:23
  • 2
    This is incorrect: the point of the dictionary is to attack the plaintext, not the password; it doesn't bruteforce the password at all. Definitely do use gpg or another tool designed for encryption rather than Vim's built-in support. May 5, 2021 at 15:07
  • @DavidLeadbeater I converted your answer to a comment (you mentioned something about replying to the comment there.) If you feel like posting a full answer to expand on it, please do so. If you do, please include enough context to allow the answer to stand on its own. Thanks for your contribution!
    – filbranden
    May 6, 2021 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.