25 lines
411 B
Go
25 lines
411 B
Go
package hashText
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
func Decode(
|
|
dirtyText, salt string,
|
|
) (string, error) {
|
|
slice := strings.Split(dirtyText, salt)
|
|
if len(slice) != 2 {
|
|
return "", errors.New("error when decoding the text")
|
|
}
|
|
|
|
// Декодируем пароль
|
|
pass, err := base64.StdEncoding.DecodeString(slice[0])
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return string(pass), nil
|
|
}
|