peridot/vendor/github.com/ProtonMail/gopenpgp/v2/internal/common.go

33 lines
824 B
Go
Raw Normal View History

2022-07-07 20:11:50 +00:00
// Package internal contains internal methods and constants.
package internal
import (
"strings"
"github.com/ProtonMail/gopenpgp/v2/constants"
)
2024-10-16 11:40:38 +00:00
func Canonicalize(text string) string {
return strings.ReplaceAll(strings.ReplaceAll(text, "\r\n", "\n"), "\n", "\r\n")
}
func TrimEachLine(text string) string {
2022-07-07 20:11:50 +00:00
lines := strings.Split(text, "\n")
for i := range lines {
lines[i] = strings.TrimRight(lines[i], " \t\r")
}
2024-10-16 11:40:38 +00:00
return strings.Join(lines, "\n")
2022-07-07 20:11:50 +00:00
}
// CreationTimeOffset stores the amount of seconds that a signature may be
// created in the future, to compensate for clock skew.
const CreationTimeOffset = int64(60 * 60 * 24 * 2)
// ArmorHeaders is a map of default armor headers.
var ArmorHeaders = map[string]string{
"Version": constants.ArmorHeaderVersion,
"Comment": constants.ArmorHeaderComment,
}