|
@@ -6,24 +6,24 @@ import (
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
-//正文
|
|
|
+// 正文
|
|
|
var SE = &SimpleEncrypt{Key: "topnet2015topnet2015"}
|
|
|
var SE2 = &SimpleEncrypt{Key: "2017jianyu"}
|
|
|
var SE3 = &SimpleEncrypt{Key: "entservice"}
|
|
|
|
|
|
-//百度
|
|
|
+// 百度
|
|
|
var BSE = &SimpleEncrypt{Key: "HNtopnet2017jy"}
|
|
|
var BSE2 = &SimpleEncrypt{Key: "TOP2017jianyu"}
|
|
|
|
|
|
-//订阅推送邮件
|
|
|
+// 订阅推送邮件
|
|
|
var ESE = &SimpleEncrypt{Key: "PEjy2018topnet"}
|
|
|
var ESE2 = &SimpleEncrypt{Key: "TopnetJy2018Pe"}
|
|
|
|
|
|
-//首页
|
|
|
+// 首页
|
|
|
var ISE = &SimpleEncrypt{Key: "Indexjy2021topnet"}
|
|
|
var ISE2 = &SimpleEncrypt{Key: "TopnetJy2021Pe"}
|
|
|
|
|
|
-//通用加密
|
|
|
+// 通用加密
|
|
|
func CommonEncodeArticle(stype string, keys ...string) (id string) {
|
|
|
switch stype {
|
|
|
case "content":
|
|
@@ -33,37 +33,39 @@ func CommonEncodeArticle(stype string, keys ...string) (id string) {
|
|
|
case "mailprivate":
|
|
|
id = BEncodeArticleId2ByCheck("C", ESE, ESE2, keys...)
|
|
|
case "indexcontent":
|
|
|
- id = BEncodeArticleId2ByCheck("D", ISE, ISE2, keys...)
|
|
|
+ id = BEncodeArticleId2ByCheck("D", ISE, ISE2, keys...)
|
|
|
}
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//通用解密
|
|
|
+// 通用解密
|
|
|
func CommonDecodeArticle(stype string, id string) (res []string) {
|
|
|
- switch stype {
|
|
|
- case "content":
|
|
|
- res = BDecodeArticleId2ByCheck(id, SE, SE2)
|
|
|
- case "bdprivate":
|
|
|
- res = BDecodeArticleId2ByCheck(id, BSE, BSE2)
|
|
|
- case "mailprivate":
|
|
|
- res = BDecodeArticleId2ByCheck(id, ESE, ESE2)
|
|
|
- case "indexcontent":
|
|
|
- res = BDecodeArticleId2ByCheck(id, ISE, ISE2)
|
|
|
- case "advancedProject":
|
|
|
- res = BDecodeArticleId2ByCheck(id, SE, SE2)
|
|
|
- }
|
|
|
- return
|
|
|
+ switch stype {
|
|
|
+ case "content", "bdcontent":
|
|
|
+ res = BDecodeArticleId2ByCheck(id, SE, SE2)
|
|
|
+ case "bdprivate":
|
|
|
+ res = BDecodeArticleId2ByCheck(id, BSE, BSE2)
|
|
|
+ case "mailprivate":
|
|
|
+ res = BDecodeArticleId2ByCheck(id, ESE, ESE2)
|
|
|
+ case "indexcontent":
|
|
|
+ res = BDecodeArticleId2ByCheck(id, ISE, ISE2)
|
|
|
+ case "advancedProject":
|
|
|
+ res = BDecodeArticleId2ByCheck(id, SE, SE2)
|
|
|
+ case "entservice":
|
|
|
+ res = []string{SE3.DecodeString(id)}
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-//短地址加密,二次加密带校验和
|
|
|
+// 短地址加密,二次加密带校验和
|
|
|
func BEncodeArticleId2ByCheck(h string, s1, s2 *SimpleEncrypt, keys ...string) string {
|
|
|
kstr := strings.Join(keys, ",")
|
|
|
kstr = s1.EncodeStringByCheck(kstr)
|
|
|
return url.QueryEscape(h + common.GetLetterRandom(2) + s2.EncodeStringByCheck(kstr))
|
|
|
}
|
|
|
|
|
|
-//短地址解密,二次解密带校验和
|
|
|
+// 短地址解密,二次解密带校验和
|
|
|
func BDecodeArticleId2ByCheck(id string, s1, s2 *SimpleEncrypt) []string {
|
|
|
if !strings.Contains(id, "+") { //新加密算法解密
|
|
|
id, _ = url.QueryUnescape(id)
|