diff --git a/src/unstable/Picocrypt.go b/src/unstable/Picocrypt.go index 892b76b..515b2e3 100644 --- a/src/unstable/Picocrypt.go +++ b/src/unstable/Picocrypt.go @@ -23,8 +23,10 @@ import ( "math" "time" "sync" + "hash" "image" "bytes" + "regexp" "strings" "strconv" "runtime" @@ -630,12 +632,31 @@ func onDrop(names []string){ // Open input file in read-only mode fin,_ := os.Open(names[0]) + // Use regex to test if input is a valid Picocrypt volume + tmp := make([]byte,30) + fin.Read(tmp) + if string(tmp[:5])=="v1.13"{ + resetUI() + _status = "Please use Picocrypt v1.13 to decrypt this file." + _status_color = color.RGBA{0xff,0x00,0x00,255} + fin.Close() + return + } + if valid,_:=regexp.Match(`^v\d\.\d{2}.{10}0?\d+`,tmp);!valid{ + resetUI() + _status = "This doesn't seem to be a Picocrypt file." + _status_color = color.RGBA{0xff,0x00,0x00,255} + fin.Close() + return + } + fin.Seek(0,0) + // Read metadata and insert into box var err error fin.Read(make([]byte,15)) - tmp := make([]byte,30) + tmp = make([]byte,15) fin.Read(tmp) - tmp,err = rsDecode(rs10,tmp) + tmp,err = rsDecode(rs5,tmp) if err==nil{ metadataLength,_ := strconv.Atoi(string(tmp)) @@ -644,7 +665,7 @@ func onDrop(names []string){ metadata = "" for i:=0;i