redacted / XKCD-password-generator

Generate secure multiword passwords/passphrases, inspired by XKCD
BSD 3-Clause "New" or "Revised" License
1.32k stars 185 forks source link

[FR] copy to clipboard #119

Closed fazlerabbi37 closed 4 years ago

fazlerabbi37 commented 4 years ago

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.

redacted commented 4 years ago

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?

fazlerabbi37 commented 4 years ago

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.

redacted commented 4 years ago

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

fazlerabbi37 commented 4 years ago

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 :smile:

ghyde commented 4 years ago

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

ghyde commented 4 years ago

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?

redacted commented 4 years ago

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.

jwfh commented 4 years ago

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!