Exemplo n.º 1
0
// 破解图案解锁的密码
func main() {
	if len(os.Args) < 2 {
		fmt.Println("usage: <gesture.key path>\ngesture.key: you can found it in /data/system/gesture.key from the android device.")
		os.Exit(0)
	}
	gestureKeyPath := os.Args[1]
	fd, err := os.Open(gestureKeyPath)
	util.CheckErr(err)
	data, err := ioutil.ReadAll(fd)
	util.CheckErr(err)
	originKey := hex.EncodeToString(data)
	//fmt.Println(originKey)
	fmt.Println(strings.Join(find(originKey), " "))
}
Exemplo n.º 2
0
// 删除重复的文件
func main() {
	if len(os.Args) < 2 {
		return
	}
	dir := os.Args[1]
	fis, err := ioutil.ReadDir(dir)
	util.CheckErr(err)
	md5s := make(map[string]bool)
	for _, fi := range fis {
		if fi.IsDir() {
			continue
		}
		filePath := dir + "/" + fi.Name()
		fd, err := os.Open(filePath)
		if err != nil {
			continue
		}
		h := md5.New()
		io.Copy(h, fd)
		fd.Close()
		md5Str := hex.EncodeToString(h.Sum(nil))
		if _, exist := md5s[md5Str]; exist == false {
			md5s[md5Str] = true
		} else {
			fmt.Println("remove: ", filePath)
			err := os.Remove(filePath)
			if err != nil {
				fmt.Println(err)
			}
		}
	}
}
Exemplo n.º 3
0
func sum(val string) string {
	data, err := hex.DecodeString(val)
	util.CheckErr(err)
	h := sha1.New()
	h.Write(data)
	return hex.EncodeToString(h.Sum(nil))
}
Exemplo n.º 4
0
Arquivo: image.go Projeto: noverguo/go
// 改变图像大小
func ResizeImage(inPath, outPath string, width, height uint) {
	file, err := os.Open(inPath)
	util.CheckErr(err)

	// decode jpeg into image.Image
	img, err := jpeg.Decode(file)
	util.CheckErr(err)

	file.Close()

	// resize to width 1000 using Lanczos resampling
	// and preserve aspect ratio
	m := resize.Resize(width, height, img, resize.Lanczos3)
	out, err := os.Create(outPath)
	util.CheckErr(err)
	defer out.Close()

	// write new image to file
	jpeg.Encode(out, m, nil)
}
Exemplo n.º 5
0
Arquivo: face.go Projeto: noverguo/go
// 通过face++ API进行人脸检测
func FaceDetect_faceplusplus(fileName string) *Faces {
	params := make(map[string]string)
	params["api_key"] = "7b73aadfe253b1e6b1db1f9037dd46de"
	params["api_secret"] = "hqm2yQthlRydFdvLBkHRfw59JDfcE8KX"
	req, err := util.NewFileUploadRequest("http://apicn.faceplusplus.com/v2/detection/detect", params, "img", fileName)
	util.CheckErr(err)

	resp, err := http.DefaultClient.Do(req)
	util.CheckErr(err)
	if resp.StatusCode != 200 {
		fmt.Println("\thttp status: ", resp.StatusCode)
		return nil
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	util.CheckErr(err)

	fs := &Faces{}
	err = json.Unmarshal(body, &fs)
	util.CheckErr(err)
	return fs
}
Exemplo n.º 6
0
func find(originKey string) []string {
	arr := []string{"00", "01", "02", "03", "04", "05", "06", "07", "08"}
	p, err := permutation.NewPerm(arr, nil) //generate a Permutator
	util.CheckErr(err)
	for i, err := p.Next(); err == nil; i, err = p.Next() {
		vals := i.([]string)
		for i := 4; i <= len(arr); i++ {
			info := strings.Join(vals[0:i], "")
			//fmt.Println(info)
			tmpKey := sum(info)
			//fmt.Println(vals, tmpKey)
			if tmpKey == originKey {
				return vals[0:i]
			}
		}
	}

	return nil
}