Last active
March 23, 2023 17:11
-
-
Save leucos/5a44b2ba5c85f6591a39147d618ce104 to your computer and use it in GitHub Desktop.
Vade Retro Spamcause (X-VR-SPAMCAUSE) Golang decoder
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
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func main() { | |
if len(os.Args) != 2 { | |
fmt.Println("usage: spamcause gggruggvucft...") | |
os.Exit(1) | |
} | |
b := []byte(os.Args[1]) | |
res := []byte{} | |
odd := false | |
err := false | |
for i := 0; i < len(b)/2; i++ { | |
var first, sec byte | |
if odd { | |
first, sec = b[2*i : 2*i+1][0], b[2*i+1 : 2*i+2][0] | |
} else { | |
sec, first = b[2*i : 2*i+1][0], b[2*i+1 : 2*i+2][0] | |
} | |
odd = !odd | |
if first >= 0x63 && first <= 0x6f { | |
res = append(res, (first-0x62)*0x11+sec-0x66) | |
} else { | |
err = true | |
res = append(res, 0x3f) | |
} | |
if err { | |
fmt.Printf("got error with record: %x %x\n", first, sec) | |
} | |
} | |
fmt.Printf("%s\n", res) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment