Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | initial import |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | descendants | trunk |
Files: | files | file ages | folders |
SHA3-256: |
a63f5b3a5fc8c313e64004b65954d1bb |
User & Date: | jef@foutaise.org 2015-11-23 18:18:32 |
Context
2015-11-23
| ||
18:33 | Create README.md check-in: e918e2a37d user: jef@foutaise.org tags: trunk | |
18:18 | initial import check-in: a63f5b3a5f user: jef@foutaise.org tags: trunk | |
Changes
Added LICENSE.
> > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
The MIT License (MIT) Copyright (c) 2015 Gérôme Fournier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Added passwordstore.go.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
// Password store (pass) library (http://www.passwordstore.org/) // Copyright (c) 2015 Gerome Fournier package passwordstore import ( "errors" "fmt" "os/exec" "strconv" "strings" ) // name of the passwordstore command const passCommand = "pass" func head(str string) string { return strings.Split(str, "\n")[0] } func pass(args ...string) (string, error) { out, err := exec.Command(passCommand, args...).CombinedOutput() if err != nil { return "", errors.New(string(out)) } return string(out), nil } // Get a password from the password store func Get(entry string) (string, error) { out, err := pass("show", entry) if err != nil { return "", err } return head(string(out)), nil } // Insert a new entry in the password store func Insert(entry, passwd string) error { cmd := exec.Command(passCommand, "insert", entry) stdin, err := cmd.StdinPipe() if err != nil { return err } input := fmt.Sprintf("%s\n%s\n", passwd, passwd) _, err = stdin.Write([]byte(input)) if err != nil { return err } stdin.Close() out, err := cmd.CombinedOutput() if err != nil { return errors.New(string(out)) } return nil } // Insert a new entry in the password store, // generate a random password of <length> characters func Generate(entry string, length int) (string, error) { _, err := pass("generate", entry, strconv.Itoa(length)) if err != nil { return "", err } return Get(entry) } // Delete an entry in the password store func Delete(entry string) error { _, err := pass("rm", entry) return err } // Rename an entry in the password store func Move(entry, newentry string) error { _, err := pass("mv", entry, newentry) return err } // Copy an entry in the password store func Copy(entry, newentry string) error { _, err := pass("cp", entry, newentry) return err } // Get a password from the password store, // then copy it to the clipboard func CopyToClipboard(entry string) error { _, err := pass("show", "-c", entry) return err } |