redacted / XKCD-password-generator

Generate secure multiword passwords/passphrases, inspired by XKCD

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FR] copy to clipboard

fazlerabbi37 opened this issue · comments

Normally we use xkcdpass when we are trying to create an account or change password. Instead of print the password to terminal which remains in the history and could be retrieved from bash history later, why not copy the pass to clipboard so that the user can paste it in the password box. This will make the workflow a bit secure.

Implementing clipboard support in a secure and cross-platform way is pretty challenging (not least because I don't have the ability to test many configurations). Might I suggest piping the output to a system-native clipboard tool?

  • on macOS xckdpass | pbcopy
  • on many Linux variants xckdpass | xsel or xkcdpass | xclip (with arguments to the clipboard command depending on your needs)
  • on WSL xkcdpass | clip.exe should work

Might I suggest piping the output to a system-native clipboard tool?

Right now I am doing exactly that, but I was hoping to save something built-in and more secure.

I don't know a lot about secure clipboard but may be the clipboard python package will help in teams of cross platform clipboard.

I hadn't seen that package before, thanks. Let me take a look at that and I'll see what I can do!

I hadn't seen that package before, thanks. Let me take a look at that and I'll see what I can do!

great! hope to hear from you soon 😄

Clipboard simply imports pyperclip, and pyperclip is just a wrapper for pbcopy, pbpaste, xclip, xsel, etc.

Personally, I think xkcdpass should follow the Unix philosophy, "Do One Thing And Do It Well." Adding clipboard support will add additional dependancies and complexity, where as xkcdpass | xsel -i already works as expected.

Instead of adding this feature in code, can we update the README?

Rather than increase the required dependencies, I was toying around with something like

def to_clipboard(text):
    try:
        import pyperclip
    except ImportError as e:
        print("Clipboard functionality requires pyperclip to be installed")
        raise e
    pyperclip.copy(text)

and making that an alternate codepath called depending on arguments. That said, there is a lot of assumptions throughout the code that we will just be outputting via print, so I'm not sure how safe this will be. If not feasible, I can certainly update the README.

Personally, I think xkcdpass should follow the Unix philosophy, "Do One Thing And Do It Well." Adding clipboard support will add additional dependancies and complexity, where as xkcdpass | xsel -i already works as expected.

I agree, and couldn't have said it better!