99 lines
2.7 KiB
Go
99 lines
2.7 KiB
Go
package meta
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"git.loafle.net/overflow/model/util"
|
|
)
|
|
|
|
type MetaCryptoType struct {
|
|
ID json.Number `json:"id,Number,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
Key string `json:"key,omitempty"`
|
|
CreateDate *util.Timestamp `json:"createDate,omitempty"`
|
|
}
|
|
|
|
type MetaCryptoTypeEnum int
|
|
|
|
const (
|
|
MetaCryptoTypeEnumNONE MetaCryptoTypeEnum = iota + 1
|
|
MetaCryptoTypeEnumUNKNOWN
|
|
MetaCryptoTypeEnumAES
|
|
MetaCryptoTypeEnumCIPHER
|
|
MetaCryptoTypeEnumDES
|
|
MetaCryptoTypeEnumDSA
|
|
MetaCryptoTypeEnumECDSA
|
|
MetaCryptoTypeEnumELLIPTIC
|
|
MetaCryptoTypeEnumHMAC
|
|
MetaCryptoTypeEnumMD5
|
|
MetaCryptoTypeEnumRAND
|
|
MetaCryptoTypeEnumRC4
|
|
MetaCryptoTypeEnumRSA
|
|
MetaCryptoTypeEnumSHA1
|
|
MetaCryptoTypeEnumSHA256
|
|
MetaCryptoTypeEnumSUBTLE
|
|
MetaCryptoTypeEnumTLS
|
|
MetaCryptoTypeEnumX509
|
|
MetaCryptoTypeEnumPKIX
|
|
)
|
|
|
|
var (
|
|
metaCryptoTypeEnumID = map[MetaCryptoTypeEnum]string{
|
|
MetaCryptoTypeEnumNONE: "NONE",
|
|
MetaCryptoTypeEnumUNKNOWN: "UNKNOWN",
|
|
MetaCryptoTypeEnumAES: "AES",
|
|
MetaCryptoTypeEnumCIPHER: "CIPHER",
|
|
MetaCryptoTypeEnumDES: "DES",
|
|
MetaCryptoTypeEnumDSA: "DSA",
|
|
MetaCryptoTypeEnumECDSA: "ECDSA",
|
|
MetaCryptoTypeEnumELLIPTIC: "ELLIPTIC",
|
|
MetaCryptoTypeEnumHMAC: "HMAC",
|
|
MetaCryptoTypeEnumMD5: "MD5",
|
|
MetaCryptoTypeEnumRAND: "RAND",
|
|
MetaCryptoTypeEnumRC4: "RC4",
|
|
MetaCryptoTypeEnumRSA: "RSA",
|
|
MetaCryptoTypeEnumSHA1: "SHA1",
|
|
MetaCryptoTypeEnumSHA256: "SHA256",
|
|
MetaCryptoTypeEnumSUBTLE: "SUBTLE",
|
|
MetaCryptoTypeEnumTLS: "TLS",
|
|
MetaCryptoTypeEnumX509: "X509",
|
|
MetaCryptoTypeEnumPKIX: "PKIX",
|
|
}
|
|
|
|
metaCryptoTypeEnumKey = map[string]MetaCryptoTypeEnum{
|
|
"NONE": MetaCryptoTypeEnumNONE,
|
|
"UNKNOWN": MetaCryptoTypeEnumUNKNOWN,
|
|
"AES": MetaCryptoTypeEnumAES,
|
|
"CIPHER": MetaCryptoTypeEnumCIPHER,
|
|
"DES": MetaCryptoTypeEnumDES,
|
|
"DSA": MetaCryptoTypeEnumDSA,
|
|
"ECDSA": MetaCryptoTypeEnumECDSA,
|
|
"ELLIPTIC": MetaCryptoTypeEnumELLIPTIC,
|
|
"HMAC": MetaCryptoTypeEnumHMAC,
|
|
"MD5": MetaCryptoTypeEnumMD5,
|
|
"RAND": MetaCryptoTypeEnumRAND,
|
|
"RC4": MetaCryptoTypeEnumRC4,
|
|
"RSA": MetaCryptoTypeEnumRSA,
|
|
"SHA1": MetaCryptoTypeEnumSHA1,
|
|
"SHA256": MetaCryptoTypeEnumSHA256,
|
|
"SUBTLE": MetaCryptoTypeEnumSUBTLE,
|
|
"TLS": MetaCryptoTypeEnumTLS,
|
|
"X509": MetaCryptoTypeEnumX509,
|
|
"PKIX": MetaCryptoTypeEnumPKIX,
|
|
}
|
|
)
|
|
|
|
func (e MetaCryptoTypeEnum) String() string {
|
|
return metaCryptoTypeEnumID[e]
|
|
}
|
|
|
|
func ToMetaCryptoTypeEnum(v *MetaCryptoType) MetaCryptoTypeEnum {
|
|
return metaCryptoTypeEnumKey[v.Key]
|
|
}
|
|
|
|
func ToMetaCryptoType(v MetaCryptoTypeEnum) *MetaCryptoType {
|
|
return &MetaCryptoType{
|
|
Key: metaCryptoTypeEnumID[v],
|
|
}
|
|
}
|