style:包名小写

This commit is contained in:
Mmx
2021-07-11 12:02:42 +08:00
parent 78e9aa9ec3
commit e3f668c100
14 changed files with 51 additions and 50 deletions

37
util/XBase64.go Normal file
View File

@@ -0,0 +1,37 @@
package util
func getbyte(a byte) int {
x := int(a)
if x > 255 {
Log.Fatalln("INVALID_CHARACTER_ERR: DOM Exception 5")
}
return x
}
func Base64(s []byte) string {
const ALPHA = "LVoJPiCN2R8G90yg+hmFHuacZ1OWMnrsSTXkYpUq/3dlbfKwv6xztjI7DeBE45QA"
const PADCHAR = "="
i := 0
b10 := 0
var x []byte
imax := len(s) - len(s)%3
if len(s) == 0 {
return ""
}
for i := 0; i < imax; i += 3 {
b10 = (getbyte(s[i]) << 16) | (getbyte(s[i+1]) << 8) | (getbyte(s[i+2]))
x = append(x, ALPHA[(b10>>18)])
x = append(x, ALPHA[((b10>>12)&63)])
x = append(x, ALPHA[((b10>>6)&63)])
x = append(x, ALPHA[(b10&63)])
}
i = imax
if len(s)-imax == 1 {
b10 = getbyte(s[i]) << 16
x = append(x, ALPHA[(b10>>18)], ALPHA[((b10>>12)&63)], PADCHAR[0], PADCHAR[0])
} else if len(s)-imax == 2 {
b10 = (getbyte(s[i]) << 16) | (getbyte(s[i+1]) << 8)
x = append(x, ALPHA[(b10>>18)], ALPHA[((b10>>12)&63)], ALPHA[((b10>>6)&63)], PADCHAR[0])
}
return string(x)
}