func MakeCert() { var err error var cert *goio.Cert private := "private.pem" public := "public.pem" if cert, err = goio.MakeCert("intel", 2048, []string{"localhost"}, 30*time.Minute, false); err != nil { panic(err) } cert.WritePrivate(private) cert.WritePublic(public) }
func main() { var err error targetDirPath := "c:/src/intel/src/github.com/vizidrix/inde-web" fileWhiteList := []string{ "*.js", "*.html", "*.png", "*.css", "*.ttf", } if len(os.Args) > 1 { var cert *goio.Cert if os.Args[1] == "cert" { if cert, err = goio.MakeCert("intel", 2048, []string{"localhost"}, 30*time.Minute, false); err != nil { panic(err) } cert.WritePrivate("private.pem") cert.WritePublic("public.pem") return } } //decodeString := "intelinde" //hash := sha256.Sum256([]byte(decodeString)) //key := hash[:] buffer := new(bytes.Buffer) //aes_w_handle, _ := aes.NewWriter(buffer, key) //zip_w_handle, _ := gzip.NewWriterLevel(aes_w_handle, gzip.BestCompression) //zip_w_handle, _ := gzip.NewWriterLevel(buffer, gzip.BestCompression) //tar_w_handle := tar.NewWriter(zip_w_handle) tar_w_handle := tar.NewWriter(buffer) writeDir(tar_w_handle, targetDirPath, "", fileWhiteList) /* files, _ := ioutil.ReadDir(targetDirPath) for _, file := range files { if !file.IsDir() { fmt.Printf("Writing file: %s\n", file.Name()) if err = writeFile(tar_w_handle, targetDirPath+"/"+file.Name()); err != nil { fmt.Printf("Error writing file: %s\n", err) return } } } */ if err = tar_w_handle.Close(); err != nil { fmt.Printf("Error closing tar:\n\t- %s\n", err) } /* if err = zip_w_handle.Close(); err != nil { fmt.Printf("Error closing zip:\n\t- %s\n", err) } */ //aes_w_handle.Close() ioutil.WriteFile("indeweb.tar", buffer.Bytes(), 0666) }