master
Felix Pankratz 1 year ago
commit aedc80a555

@ -0,0 +1,26 @@
# password generate
Generate random passwords. Password is written to stdout and copied to the windows clipboard.
Place both scripts somewhere in your `%PATH%` on Windows, then execute `pw <num` from the "Run" window.
Usage:
```
./pw.py <length of password>
```
e.g.
```
./pw.py 32
```
### vim Shortcut
```
let pwcmd = 'cmd.exe /c "python C:\\Tools\\pw.py 10" |tr -d "\\n"|tr -d "\\r"'
:nmap <F8> "=system(pwcmd)<C-M>p
:imap <F8> <C-R>=system(pwcmd)<C-M>
```

@ -0,0 +1 @@
python C:\Tools\pw.py %*

28
pw.py

@ -0,0 +1,28 @@
#!/usr/bin/env python3
import random
def generate_pw(length):
import string
charset = string.ascii_letters + string.digits + '+-_?!.:,;';
return ''.join([random.choice(charset) for _ in range(length)])
def main():
import sys
import os
import time
import win32clipboard
if len(sys.argv) > 1:
length = int(sys.argv[1])
else:
length = 12
pw = generate_pw(length)
print(pw)
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(pw, win32clipboard.CF_UNICODETEXT)
win32clipboard.CloseClipboard()
if __name__ == '__main__':
main()
Loading…
Cancel
Save