(data string)
| 98 | return hash[:] |
| 99 | } |
| 100 | func Decrypt(data string) (string, error) { |
| 101 | if data == "" { |
| 102 | return "", fmt.Errorf("empty data") |
| 103 | } |
| 104 | |
| 105 | buf, err := base64.StdEncoding.DecodeString(data) |
| 106 | if err != nil { |
| 107 | return "", err |
| 108 | } |
| 109 | |
| 110 | head := buf[:8] |
| 111 | d := buf[8:] |
| 112 | |
| 113 | key := randomKey(head) |
| 114 | |
| 115 | bt, err := desDecode(d, key) |
| 116 | if err != nil { |
| 117 | return "", err |
| 118 | } |
| 119 | |
| 120 | return removeNonPrintableChars(string(bt)), nil |
| 121 | } |
no test coverage detected