Skip to content

Commit 8ebf15b

Browse files
author
jhin
committed
再次修复win下空白格问题
1 parent ded5a89 commit 8ebf15b

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

dict/weak_pass_keyboard_walk.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ p4ssw0rd!
304304
P4ssw0rd1
305305
P4ssw0rd!
306306
qwertyuiop[]\
307-
asdfghjkl;��
307+
asdfghjkl;
308308
zxcvbnm,./
309309
/.,mnbvcxz
310-
��;lkjhgfdsa
310+
;lkjhgfdsa
311311
\][poiuytrewq
312312
qwertyuiop[]
313313
1qaz2wsx!@

lib_core/fileHandle.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package lib_core
22

33
import (
44
"bufio"
5+
"io"
56
"os"
67
"pwdgenerator/gologger"
78
)
@@ -20,13 +21,19 @@ func FileLoad(file_path string , bufSize int) string{
2021
r := bufio.NewReader(file)
2122
b := make([]byte, bufSize)
2223
for {
23-
_, err := r.Read(b)
24+
n, err := r.Read(b)
25+
chunk = append(chunk,b[:n]...)
2426
if err != nil {
25-
//gologger.Printf("Error reading file:", err)
26-
break
27+
if err == io.EOF {
28+
err = nil
29+
break
30+
} else {
31+
gologger.Errorf("%s",err)
32+
os.Exit(-1)
33+
}
2734
}
2835
//res = string(b)
29-
chunk = append(chunk,b...)
36+
3037

3138
}
3239
res = string(chunk)

lib_core/generatePass.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
//处理常规密码生成
1010
func AddCommonPass(file *os.File) bool {
1111

12-
res := FileLoad(common_passFile, 1000000)
12+
res := FileLoad(common_passFile, 1024)
1313
//f ,err := os.OpenFile(commonpassFile,os.O_APPEND,0666)
1414
//check(err)
1515
//defer f.Close()
@@ -35,7 +35,10 @@ func AddRulePass(file *os.File, key string) bool {
3535

3636
if len(result_list) != 0 {
3737
for _, pass := range result_list {
38-
pass = pass + "\n"
38+
pass = strings.Replace(pass, " ", "", -1)
39+
pass = strings.Replace(pass, "\n", "", -1)
40+
pass = strings.Replace(pass, "\r", "", -1)
41+
pass = pass + "\r\n"
3942
file.WriteString(pass)
4043
}
4144
}
@@ -78,7 +81,6 @@ func RuleGotPass(key string, rule []string) []string {
7881
//}
7982
tmp = []string{}
8083

81-
8284
}
8385

8486
} else {
@@ -105,10 +107,10 @@ func CheckFormat(k string) bool {
105107
func GetListByFormat(k string, key string) []string {
106108
var special_letter = []string{"!", "@", "#", "$", "%", "*"}
107109
var year = []string{"2015", "2016", "2017", "2018", "2019", "2020"}
108-
china_name := FileLoad(china_nameFile, 10000)
109-
keyboard_walk := FileLoad(keyboard_walkFile, 10000)
110-
common_number := FileLoad(common_numberFile, 10000)
111-
common_pass := FileLoad(common_passFile, 10000)
110+
china_name := FileLoad(china_nameFile, 1024)
111+
keyboard_walk := FileLoad(keyboard_walkFile, 1024)
112+
common_number := FileLoad(common_numberFile, 1024)
113+
common_pass := FileLoad(common_passFile, 1024)
112114
var list = []string{}
113115
switch k {
114116
case "key":
@@ -139,7 +141,7 @@ func GetListByFormat(k string, key string) []string {
139141
return list
140142
}
141143
func AddKeyboardPass(file *os.File) bool{
142-
res := FileLoad(keyboard_pass, 1000000)
144+
res := FileLoad(keyboard_pass, 1024)
143145
//f ,err := os.OpenFile(commonpassFile,os.O_APPEND,0666)
144146
//check(err)
145147
//defer f.Close()

pwdgenerator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"pwdgenerator/gologger"
66
)
77

8-
const version = "0.1"
8+
const version = "0.9.1"
99
const banner = `
1010
1111
.___ __

0 commit comments

Comments
 (0)