Use native clipboard
This commit is contained in:
parent
d59b99a43d
commit
b3dc607e05
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Picocrypt v1.30
|
Picocrypt v1.31
|
||||||
Copyright (c) Evan Su
|
Copyright (c) Evan Su
|
||||||
Released under a GNU GPL v3 License
|
Released under a GNU GPL v3 License
|
||||||
https://github.com/HACKERALERT/Picocrypt
|
https://github.com/HACKERALERT/Picocrypt
|
||||||
|
@ -32,7 +32,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/HACKERALERT/clipboard"
|
|
||||||
"github.com/HACKERALERT/crypto/argon2"
|
"github.com/HACKERALERT/crypto/argon2"
|
||||||
"github.com/HACKERALERT/crypto/blake2b"
|
"github.com/HACKERALERT/crypto/blake2b"
|
||||||
"github.com/HACKERALERT/crypto/chacha20"
|
"github.com/HACKERALERT/crypto/chacha20"
|
||||||
|
@ -59,7 +58,7 @@ var TRANSPARENT = color.RGBA{0x00, 0x00, 0x00, 0x00}
|
||||||
|
|
||||||
// Generic variables
|
// Generic variables
|
||||||
var window *giu.MasterWindow
|
var window *giu.MasterWindow
|
||||||
var version = "v1.30"
|
var version = "v1.31"
|
||||||
var dpi float32
|
var dpi float32
|
||||||
var mode string
|
var mode string
|
||||||
var working bool
|
var working bool
|
||||||
|
@ -182,9 +181,7 @@ func draw() {
|
||||||
giu.Checkbox("Lowercase", &passgenLower),
|
giu.Checkbox("Lowercase", &passgenLower),
|
||||||
giu.Checkbox("Numbers", &passgenNums),
|
giu.Checkbox("Numbers", &passgenNums),
|
||||||
giu.Checkbox("Symbols", &passgenSymbols),
|
giu.Checkbox("Symbols", &passgenSymbols),
|
||||||
giu.Style().SetDisabled(clipboard.Unsupported).To(
|
|
||||||
giu.Checkbox("Copy to clipboard", &passgenCopy),
|
giu.Checkbox("Copy to clipboard", &passgenCopy),
|
||||||
),
|
|
||||||
giu.Row(
|
giu.Row(
|
||||||
giu.Button("Cancel").Size(100, 0).OnClick(func() {
|
giu.Button("Cancel").Size(100, 0).OnClick(func() {
|
||||||
giu.CloseCurrentPopup()
|
giu.CloseCurrentPopup()
|
||||||
|
@ -339,16 +336,14 @@ func draw() {
|
||||||
}),
|
}),
|
||||||
giu.Tooltip("Clear the password entries."),
|
giu.Tooltip("Clear the password entries."),
|
||||||
|
|
||||||
giu.Style().SetDisabled(clipboard.Unsupported).To(
|
|
||||||
giu.Row(
|
|
||||||
giu.Button("Copy").Size(54, 0).OnClick(func() {
|
giu.Button("Copy").Size(54, 0).OnClick(func() {
|
||||||
clipboard.WriteAll(password)
|
giu.Context.GetPlatform().SetClipboard(password)
|
||||||
giu.Update()
|
giu.Update()
|
||||||
}),
|
}),
|
||||||
giu.Tooltip("Copy the password into your clipboard."),
|
giu.Tooltip("Copy the password into your clipboard."),
|
||||||
|
|
||||||
giu.Button("Paste").Size(54, 0).OnClick(func() {
|
giu.Button("Paste").Size(54, 0).OnClick(func() {
|
||||||
tmp, _ := clipboard.ReadAll()
|
tmp := giu.Context.GetPlatform().GetClipboard()
|
||||||
password = tmp
|
password = tmp
|
||||||
if mode != "decrypt" {
|
if mode != "decrypt" {
|
||||||
cpassword = tmp
|
cpassword = tmp
|
||||||
|
@ -357,8 +352,6 @@ func draw() {
|
||||||
giu.Update()
|
giu.Update()
|
||||||
}),
|
}),
|
||||||
giu.Tooltip("Paste a password from your clipboard."),
|
giu.Tooltip("Paste a password from your clipboard."),
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
giu.Style().SetDisabled(mode == "decrypt").To(
|
giu.Style().SetDisabled(mode == "decrypt").To(
|
||||||
giu.Button("Create").Size(54, 0).OnClick(func() {
|
giu.Button("Create").Size(54, 0).OnClick(func() {
|
||||||
|
@ -782,7 +775,7 @@ func onDrop(names []string) {
|
||||||
tmp := make([]byte, 15)
|
tmp := make([]byte, 15)
|
||||||
fin.Read(tmp)
|
fin.Read(tmp)
|
||||||
tmp, err = rsDecode(rs5, tmp)
|
tmp, err = rsDecode(rs5, tmp)
|
||||||
if valid, _ := regexp.Match(`^v\d\.\d{2}`, tmp); !valid || err != nil {
|
if valid, _ := regexp.Match(`^v1\.\d{2}`, tmp); !valid || err != nil {
|
||||||
resetUI()
|
resetUI()
|
||||||
mainStatus = "This doesn't seem like a Picocrypt volume."
|
mainStatus = "This doesn't seem like a Picocrypt volume."
|
||||||
mainStatusColor = RED
|
mainStatusColor = RED
|
||||||
|
@ -1883,7 +1876,7 @@ func resetUI() {
|
||||||
passgenLower = true
|
passgenLower = true
|
||||||
passgenNums = true
|
passgenNums = true
|
||||||
passgenSymbols = true
|
passgenSymbols = true
|
||||||
passgenCopy = !clipboard.Unsupported
|
passgenCopy = true
|
||||||
|
|
||||||
keyfile = false
|
keyfile = false
|
||||||
keyfiles = nil
|
keyfiles = nil
|
||||||
|
@ -1984,7 +1977,7 @@ func genPassword() string {
|
||||||
tmp[i] = chars[j.Int64()]
|
tmp[i] = chars[j.Int64()]
|
||||||
}
|
}
|
||||||
if passgenCopy {
|
if passgenCopy {
|
||||||
clipboard.WriteAll(string(tmp))
|
giu.Context.GetPlatform().SetClipboard(string(tmp))
|
||||||
}
|
}
|
||||||
return string(tmp)
|
return string(tmp)
|
||||||
}
|
}
|
||||||
|
@ -2039,11 +2032,6 @@ func main() {
|
||||||
// Set universal DPI
|
// Set universal DPI
|
||||||
dpi = giu.Context.GetPlatform().GetContentScale()
|
dpi = giu.Context.GetPlatform().GetContentScale()
|
||||||
|
|
||||||
// Check for clipboard support
|
|
||||||
if clipboard.Unsupported {
|
|
||||||
mainStatus = "Ready. (Note: No clipboard support found.)"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the UI
|
// Start the UI
|
||||||
window.Run(draw)
|
window.Run(draw)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ module Picocrypt
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/HACKERALERT/clipboard v0.1.5-0.20220507233423-cccec4a4226a
|
|
||||||
github.com/HACKERALERT/crypto v0.0.0-20220905152506-aa0dd62d8f67
|
github.com/HACKERALERT/crypto v0.0.0-20220905152506-aa0dd62d8f67
|
||||||
github.com/HACKERALERT/dialog v0.0.0-20220508022504-af3bc34fe379
|
github.com/HACKERALERT/dialog v0.0.0-20220508022504-af3bc34fe379
|
||||||
github.com/HACKERALERT/giu v0.5.7-0.20221117223150-211c1da061d9
|
github.com/HACKERALERT/giu v0.5.7-0.20221117223150-211c1da061d9
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
github.com/HACKERALERT/clipboard v0.1.5-0.20220507233423-cccec4a4226a h1:AJwVJ8FRAwocNV6jjwcexiMIH0q+LvDxGpln9tLBZ/8=
|
|
||||||
github.com/HACKERALERT/clipboard v0.1.5-0.20220507233423-cccec4a4226a/go.mod h1:io5lk+xSkGqXRrXYAtBjyIpUBH9yPmbwyMPvBUmCNeg=
|
|
||||||
github.com/HACKERALERT/crypto v0.0.0-20220905152506-aa0dd62d8f67 h1:4WfPIopYjvBjyDg0IET7mEj32kkihLmvFgwCOmldqK8=
|
github.com/HACKERALERT/crypto v0.0.0-20220905152506-aa0dd62d8f67 h1:4WfPIopYjvBjyDg0IET7mEj32kkihLmvFgwCOmldqK8=
|
||||||
github.com/HACKERALERT/crypto v0.0.0-20220905152506-aa0dd62d8f67/go.mod h1:qiHCxMDsCxX4QhXd3kDYWiNOR/DZQZ7nYO/f2OgWst0=
|
github.com/HACKERALERT/crypto v0.0.0-20220905152506-aa0dd62d8f67/go.mod h1:qiHCxMDsCxX4QhXd3kDYWiNOR/DZQZ7nYO/f2OgWst0=
|
||||||
github.com/HACKERALERT/dialog v0.0.0-20220508022504-af3bc34fe379 h1:GR92LbksZ8zdbzQHf2dTI7e7P8Mjbdi5mSmQv2SK2Uw=
|
github.com/HACKERALERT/dialog v0.0.0-20220508022504-af3bc34fe379 h1:GR92LbksZ8zdbzQHf2dTI7e7P8Mjbdi5mSmQv2SK2Uw=
|
||||||
|
|
Loading…
Reference in New Issue