Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- import "math"
- import "strconv"
- import "os"
- func init() {
- if len(os.Args) != 3 {
- fmt.Fprintln(os.Stderr, "wrong number of args")
- os.Exit(1)
- }
- mathId = os.Args[1]
- activationKey = os.Args[2]
- }
- // var mathId = document.getElementById("str").value;
- var mathId string
- // var activationKey = document.getElementById("act").value;
- var activationKey string
- func f1(n int, b byte, c int) int {
- for bitIndex := 0; bitIndex <= 7; bitIndex++ {
- bit := (b >> uint8(bitIndex)) & 1
- if int(bit)+((n-int(bit)) & ^1) == n {
- n = (n - int(bit)) >> 1
- } else {
- n = ((c - int(bit)) ^ n) >> 1
- }
- }
- return n
- }
- // str is fmt.Sprintf("%s$1&%s", mathId, activationKey)
- func genPassword(mathId, activationKey string) string {
- str := fmt.Sprintf("%s$1&%s", mathId, activationKey)
- hash := 0xA439
- for byteIndex := len(str) - 1; byteIndex >= 0; byteIndex -= 1 {
- hash = f1(hash, byte(str[byteIndex]), 0x105C3)
- }
- n1 := 0
- for f1(f1(hash, byte(n1&0xFF), 0x105C3), byte(n1>>8), 0x105C3) != 0xA5B6 {
- n1 += 1
- if n1 >= 0xFFFF {
- panic(fmt.Errorf("Error"))
- }
- }
- n1 = int(math.Floor(float64((n1+0x72FA)&0xFFFF) * 99999.0 / 0xFFFF))
- n1str := fmt.Sprintf("0000%d", n1)
- n1str = n1str[len(n1str)-5:]
- temp, _ := strconv.Atoi(n1str[0:2] + n1str[3:] + n1str[2:3]) // 12 + 45 + 3
- temp = int(math.Ceil((float64(temp) / 99999.0) * 0xFFFF))
- temp = f1(f1(0, byte(temp&0xFF), 0x1064B), byte(temp>>8), 0x1064B)
- for byteIndex := len(str) - 1; byteIndex >= 0; byteIndex-- {
- temp = f1(temp, byte(str[byteIndex]), 0x1064B)
- }
- n2 := 0
- for f1(f1(temp, byte(n2&0xFF), 0x1064B), byte(n2>>8), 0x1064B) != 0xA5B6 {
- n2 += 1
- if n2 >= 0xFFFF {
- panic(fmt.Errorf("Error"))
- }
- }
- n2 = int(math.Floor(float64(n2&0xFFFF) * 99999.0 / 0xFFFF))
- n2str := fmt.Sprintf("0000%d", n2)
- n2str = n2str[len(n2str)-5:]
- return n2str[3:4] +
- n1str[3:4] +
- n1str[1:2] +
- n1str[0:1] +
- "-" +
- n2str[4:5] +
- n1str[2:3] +
- n2str[0:1] +
- "-" +
- n2str[2:3] +
- n1str[4:5] +
- n2str[1:2] +
- "::1"
- }
- func main() {
- fmt.Println(genPassword(mathId, activationKey))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement