Skip to content

Commit 65d1e20

Browse files
committed
Initial code.
0 parents  commit 65d1e20

File tree

6 files changed

+351
-0
lines changed

6 files changed

+351
-0
lines changed

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Ignore vendor directory
15+
vendor/
16+
17+
# Ignore dist binaries
18+
/dist/

Gopkg.lock

+183
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
#
22+
# [prune]
23+
# non-go = false
24+
# go-tests = true
25+
# unused-packages = true
26+
27+
28+
[[constraint]]
29+
name = "github.com/manifoldco/promptui"
30+
version = "0.3.2"
31+
32+
[prune]
33+
go-tests = true
34+
unused-packages = true

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Rafael Cossovan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

build-all.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# Reference: https://github.com/containous/traefik/blob/master/script/crossbinary-default
3+
4+
set -e
5+
mkdir -p dist
6+
7+
GO_BUILD_CMD="go build"
8+
9+
OS_PLATFORM_ARG=(linux windows darwin)
10+
OS_ARCH_ARG=(amd64 386)
11+
for OS in ${OS_PLATFORM_ARG[@]}; do
12+
BIN_EXT=''
13+
if [ "$OS" == "windows" ]; then
14+
BIN_EXT='.exe'
15+
fi
16+
for ARCH in ${OS_ARCH_ARG[@]}; do
17+
echo "Building binary for ${OS}/${ARCH}..."
18+
GOARCH=${ARCH} GOOS=${OS} CGO_ENABLED=0 ${GO_BUILD_CMD} -o "dist/IniDat_${OS}-${ARCH}${BIN_EXT}" .
19+
done
20+
done

main.go

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
"io"
6+
"log"
7+
"os"
8+
"path/filepath"
9+
"strings"
10+
11+
"github.com/manifoldco/promptui"
12+
)
13+
14+
func main() {
15+
var result string
16+
if len(os.Args) == 2 {
17+
result = os.Args[1]
18+
} else {
19+
// list all files in current folder
20+
files, err := filepath.Glob("*.ini.dat")
21+
if err != nil {
22+
log.Fatalln(err)
23+
}
24+
25+
// prompt for a file
26+
prompt := promptui.Select{
27+
Label: "Select a file",
28+
Items: files,
29+
}
30+
31+
_, result, err = prompt.Run()
32+
if err != nil {
33+
log.Fatalln("Prompt failed", err)
34+
}
35+
}
36+
37+
// open file for reading
38+
fin, err := os.Open(result)
39+
if err != nil {
40+
log.Fatalln(err)
41+
}
42+
defer fin.Close()
43+
44+
// create file for writing
45+
name := strings.TrimSuffix(result, filepath.Ext(result))
46+
fout, err := os.Create(name)
47+
if err != nil {
48+
log.Fatalln(err)
49+
}
50+
defer fout.Close()
51+
52+
// encryption mask
53+
var mask = []byte{0xA1, 0xB2, 0xAA, 0x12, 0x23, 0xF1, 0xF3, 0xD3, 0x78, 0x02}
54+
buf := make([]byte, 1024)
55+
56+
br := bufio.NewReader(fin)
57+
bw := bufio.NewWriter(fout)
58+
for {
59+
n, err := br.Read(buf)
60+
if err == io.EOF {
61+
break
62+
}
63+
if err != nil {
64+
log.Fatalln(err)
65+
}
66+
67+
// apply mask
68+
for i := 0; i < n; i++ {
69+
buf[i] = buf[i] ^ mask[i%len(mask)]
70+
}
71+
bw.Write(buf[:n])
72+
}
73+
bw.Flush()
74+
75+
}

0 commit comments

Comments
 (0)