-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcryptography.go
58 lines (51 loc) · 1.09 KB
/
cryptography.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
54
55
56
57
58
package gryphon
import (
"crypto/md5"
"encoding/base64"
"encoding/hex"
"io"
"os"
)
func md5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
func ComputeMD5(filePath string) []byte {
var result []byte
file, err := os.Open(filePath)
if err != nil {
return nil
}
defer file.Close()
hash := md5.New()
if _, err := io.Copy(hash, file); err != nil {
return nil
}
return hash.Sum(result)
}
func Base64Encode(str string) string {
return base64.StdEncoding.EncodeToString([]byte(str))
}
func Base64Decode(str string) string {
data, err := base64.StdEncoding.DecodeString(str)
if err != nil {
// NewDebugUpdate("Error: None-Valid Base64 String...")
return ""
}
return string(data)
}
func Deobfuscate(Data string) string {
var ClearText string
for i := 0; i < len(Data); i++ {
ClearText += string(rune(int(Data[i]) - 1))
}
return ClearText
}
func Obfuscate(Data string) string {
var ObfuscateText string
for i := 0; i < len(Data); i++ {
ObfuscateText += string(rune(int(Data[i]) + 1))
}
return ObfuscateText
}