-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc4.go
53 lines (50 loc) · 874 Bytes
/
c4.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
package main
import (
"encoding/hex"
"bufio"
"io"
"os"
"log"
"fmt"
"./cryptutils"
)
func ReadFile() error {
f, err := os.Open("1_4.txt")
if err != nil {
fmt.Println(err)
return err
}
bf := bufio.NewReader(f)
max := -99999999.0
msg := ""
key := byte(0)
for {
line, isPrefix, err := bf.ReadLine()
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
if isPrefix {
log.Fatal("Error: Unexpected long line reading", f.Name())
}
//fmt.Println(string(line))
cgram, err := hex.DecodeString(string(line))
if err != nil {
panic("hex decode failed")
}
k, m, s, _ := cryptutils.DecryptMsg(cgram)
if s > max {
msg = m
max = s
key = k
}
}
fmt.Println(msg, max, key)
return nil
}
func main() {
//fmt.Println(DecryptMsg("1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736"))
ReadFile()
}