Created
September 10, 2021 11:04
-
-
Save toriato/0598fb9a8105662837a4f5690472d6c8 to your computer and use it in GitHub Desktop.
디시인사이드 글 작성 서비스 코드 디코더 (golang)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const decodeKey = "yL/M=zNa0bcPQdReSfTgUhViWjXkYIZmnpo+qArOBslCt2D3uE4Fv5G6wH178xJ9K" | |
func decode(keys, code string) string { | |
// common.js?v=210817:858 | |
k := [4]byte{} | |
o := strings.Builder{} | |
for c := 0; c < len(keys); { | |
for i := 0; i < len(k); i++ { | |
k[i] = byte(strings.Index(decodeKey, string(keys[c]))) | |
c += 1 | |
} | |
o.WriteByte(k[0]<<2 | k[1]>>4) | |
if k[2] != 64 { | |
o.WriteByte((15&k[1])<<4 | k[2]>>2) | |
} | |
if k[3] != 64 { | |
o.WriteByte((3&k[2])<<6 | k[3]) | |
} | |
} | |
// common.js?v=210817:862 | |
keys = o.String() | |
fi, _ := strconv.Atoi(keys[0:1]) | |
if fi > 5 { | |
fi -= 5 | |
} else { | |
fi += 4 | |
} | |
keys = string(rune(fi)) + keys[1:] | |
// common.js?v=210817:859 | |
o.Reset() | |
o.WriteString(code[:len(code)-10]) | |
for idx, s := range strings.Split(keys, ",") { | |
key, _ := strconv.ParseFloat(s, 64) | |
o.WriteByte(byte(2 * (key - float64(idx) - 1) / float64(13-idx-1))) | |
} | |
return o.String() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment