1
0
Fork 0
mirror of https://github.com/HACKERALERT/Picocrypt.git synced 2024-09-20 09:46:43 +00:00

Update Picocrypt.go

This commit is contained in:
Evan Su 2021-08-29 15:04:23 -04:00 committed by GitHub
parent e5db555c52
commit b5b6ade0ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -226,15 +226,15 @@ func startUI(){
giu.Custom(func(){ giu.Custom(func(){
// Language dropdown menu // Language dropdown menu
pos := giu.GetCursorPos() pos := giu.GetCursorPos()
w,_ := giu.CalcTextSize(languages[languageSelected])
giu.Row( giu.Row(
giu.Dummy(-108,0), giu.Dummy(-w-32,0),
giu.Combo("##language",languages[languageSelected],languages,&languageSelected).OnChange(func(){ giu.Combo("##language",languages[languageSelected],languages,&languageSelected).OnChange(func(){
selectedLocale = allLocales[languageSelected] selectedLocale = allLocales[languageSelected]
shredding = s(shredding) shredding = s(shredding)
}).Size(100), }).Size(w+24),
).Build() ).Build()
giu.SetCursorPos(pos) giu.SetCursorPos(pos)
// The tab bar, which contains different tabs for different functions // The tab bar, which contains different tabs for different functions
giu.TabBar().TabItems( giu.TabBar().TabItems(
// Main file encryption/decryption tab // Main file encryption/decryption tab
@ -284,6 +284,26 @@ func startUI(){
giu.Custom(func(){ giu.Custom(func(){
if showKeyfile{ if showKeyfile{
giu.PopupModal(s("Manage keyfile(s):")).Layout( giu.PopupModal(s("Manage keyfile(s):")).Layout(
giu.Label(s("Drop and drop your keyfile(s) here.")),
giu.Row(
giu.Label(s("You can also generate a keyfile:")),
giu.Button(s("Generate")).OnClick(func(){
file,_ := dialog.File().Title(s("Save keyfile as")).Save()
// Return if user canceled the file dialog
if file==""{
return
}
fout,_ := os.Create(file)
data := make([]byte,1048576)
rand.Read(data)
fout.Write(data)
fout.Close()
keyfiles = append(keyfiles,file)
}),
),
giu.Custom(func(){ giu.Custom(func(){
for _,i := range keyfiles{ for _,i := range keyfiles{
giu.Row( giu.Row(
@ -301,11 +321,12 @@ func startUI(){
} }
}), }),
giu.Dummy(0,200),
giu.Row( giu.Row(
giu.Dummy(0,300),
giu.Button(s("Clear")).Size(150,0).OnClick(func(){ giu.Button(s("Clear")).Size(150,0).OnClick(func(){
keyfiles = nil keyfiles = nil
}), }),
giu.Tooltip(s("Remove all keyfiles.")),
giu.Button(s("Done")).Size(150,0).OnClick(func(){ giu.Button(s("Done")).Size(150,0).OnClick(func(){
giu.CloseCurrentPopup() giu.CloseCurrentPopup()
showKeyfile = false showKeyfile = false
@ -463,16 +484,16 @@ func startUI(){
giu.Tooltip(s("Click to toggle the password state.")), giu.Tooltip(s("Click to toggle the password state.")),
giu.Custom(func(){ giu.Custom(func(){
if !(mode=="decrypt"&&!keyfile){ if !(mode=="decrypt"&&!keyfile){
giu.Button(s("Keyfile")).OnClick(func(){ giu.Button(s("Keyfile(s)")).OnClick(func(){
showKeyfile = true showKeyfile = true
}).Size(71,0).Build() }).Size(71,0).Build()
} }
}), }),
giu.Tooltip(s("Manage keyfile(s).")), giu.Tooltip(s("Manage your keyfile(s).")),
giu.Dummy(-0.0000001,0), giu.Dummy(-0.0000001,0),
), ),
giu.Row( giu.Row(
giu.InputText(&password).Size(440/dpi).Flags(passwordState).OnChange(func(){ giu.InputText(&password).Size(442/dpi).Flags(passwordState).OnChange(func(){
passwordStrength = zxcvbn.PasswordStrength(password,nil).Score passwordStrength = zxcvbn.PasswordStrength(password,nil).Score
}), }),
@ -516,7 +537,7 @@ func startUI(){
if mode!="decrypt"{ if mode!="decrypt"{
giu.Label(s("Confirm password:")).Build() giu.Label(s("Confirm password:")).Build()
giu.Row( giu.Row(
giu.InputText(&cPassword).Size(440/dpi).Flags(passwordState), giu.InputText(&cPassword).Size(442/dpi).Flags(passwordState),
giu.Custom(func(){ giu.Custom(func(){
canvas := giu.GetCanvas() canvas := giu.GetCanvas()
pos := giu.GetCursorScreenPos() pos := giu.GetCursorScreenPos()
@ -619,7 +640,7 @@ func startUI(){
return return
} }
if keyfile&&keyfiles==nil{ if keyfile&&keyfiles==nil{
_status = "Please select a keyfile." _status = "Please select your keyfile(s)."
_status_color = color.RGBA{0xff,0x00,0x00,255} _status_color = color.RGBA{0xff,0x00,0x00,255}
return return
} }
@ -1300,7 +1321,7 @@ func work(){
if paranoid{ if paranoid{
flags[1] = 1 flags[1] = 1
} }
if keyfile{ if len(keyfiles)>0{
flags[2] = 1 flags[2] = 1
} }
if reedsolo{ if reedsolo{
@ -1482,7 +1503,7 @@ func work(){
khash_sha3.Write(khash) khash_sha3.Write(khash)
khash_hash = khash_sha3.Sum(nil) khash_hash = khash_sha3.Sum(nil)
}*/ }*/
if len(keyfiles)>0{ if len(keyfiles)>0||keyfile{
var keysum []byte var keysum []byte
for _,path := range keyfiles{ for _,path := range keyfiles{
kin,_ := os.Open(path) kin,_ := os.Open(path)
@ -1500,7 +1521,6 @@ func work(){
keysum[i] ^= j keysum[i] ^= j
} }
} }
fmt.Println(path,keysum)
} }
khash = keysum khash = keysum
khash_sha3 := sha3.New256() khash_sha3 := sha3.New256()
@ -1536,7 +1556,7 @@ func work(){
if !keyCorrect{ if !keyCorrect{
_status = "The provided password is incorrect." _status = "The provided password is incorrect."
}else{ }else{
_status = "The provided keyfile is incorrect." _status = "Incorrect keyfile(s)."
} }
_status_color = color.RGBA{0xff,0x00,0x00,255} _status_color = color.RGBA{0xff,0x00,0x00,255}
key = nil key = nil
@ -1550,7 +1570,7 @@ func work(){
fout,_ = os.Create(outputFile) fout,_ = os.Create(outputFile)
} }
if keyfile{ if len(keyfiles)>0||keyfile{
// XOR key and keyfile // XOR key and keyfile
tmp := key tmp := key
key = make([]byte,32) key = make([]byte,32)
@ -2370,7 +2390,7 @@ func main(){
giu.SetDefaultFontFromBytes(font,18) giu.SetDefaultFontFromBytes(font,18)
// Create giu window, set window icon // Create giu window, set window icon
window := giu.NewMasterWindow("Picocrypt",482,522,giu.MasterWindowFlagsNotResizable) window := giu.NewMasterWindow("Picocrypt",482,528,giu.MasterWindowFlagsNotResizable)
r := bytes.NewReader(iconBytes) r := bytes.NewReader(iconBytes)
icon,_ := png.Decode(r) icon,_ := png.Decode(r)
window.SetIcon([]image.Image{icon}) window.SetIcon([]image.Image{icon})