Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func cksum(bytes []int) int{
- a := 0
- b := 0
- for i := 0; i < len(bytes); i++ {
- a = (a + bytes[i]) % 255
- b = (b + a) % 255
- }
- return (b << 8) | a;
- }
- package main
- import "fmt"
- import "bytes"
- var leftAnswers = []string{}
- func everyEven(bytes []int) []int {
- arr := []int{}
- for i := 0; i < len(bytes); i++ {
- if i % 2 == 0 {
- arr = append(arr, bytes[i])
- }
- }
- return arr
- }
- func toBytes(str string) []int{
- arr := []int{}
- for _,code := range str {
- arr = append(arr, int(code))
- }
- return arr
- }
- func cksum(bytes []int) int{
- a := 0
- b := 0
- for i := 0; i < len(bytes); i++ {
- a = (a + bytes[i]) % 255
- b = (b + a) % 255
- }
- return (b << 8) | a;
- }
- func brute(start int) {
- counter := 0
- alphabet := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- fmt.Println("Started", start)
- for a := start; a < len(alphabet); a++ {
- letter1 := string(alphabet[a]);
- for b := 0; b < len(alphabet); b++ {
- letter2 := string(alphabet[b]);
- for c := 0; c < len(alphabet); c++ {
- letter3 := string(alphabet[c]);
- for d := 0; d < len(alphabet); d++ {
- letter4 := string(alphabet[d]);
- for e := 0; e < len(alphabet); e++ {
- letter5 := string(alphabet[e]);
- for f := 0; f < len(alphabet); f++ {
- letter6 := string(alphabet[f]);
- counter += 1
- var buffer bytes.Buffer
- buffer.WriteString(letter1)
- buffer.WriteString(letter2)
- buffer.WriteString(letter3)
- buffer.WriteString(letter4)
- buffer.WriteString(letter5)
- buffer.WriteString(letter6)
- pw := buffer.String()
- checksum := cksum(toBytes(pw))
- go lhs(pw, checksum)
- go rhs(pw, checksum)
- if (counter % 1000000 == 0) {
- fmt.Println(start, counter, " processed")
- }
- }
- }
- }
- }
- }
- }
- }
- func lhs(pw string, checksum int) {
- if checksum == 53358 {
- leftAnswers = append(leftAnswers, pw)
- }
- }
- func rhs(pw string, checksum int) {
- if checksum == 61453 {
- go findPassword(pw)
- }
- }
- func findPassword(pw string) {
- for i := 0; i < len(leftAnswers); i++ {
- fullpw := leftAnswers[i] + pw
- bytes := toBytes(fullpw)
- evens := everyEven(bytes)
- if cksum(evens) == 0 {
- fmt.Println("THE PASSWORD IS:", fullpw)
- }
- }
- }
- func main() {
- for i := 0; i < 52; i++ {
- go brute(i)
- }
- select {}
- }
- for i := 0; i < 52; i++ {
- go brute(i)
- }
- counter := 0
- alphabet := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- fmt.Println("Started", start)
- for a := start; a < len(alphabet); a++ {
- // stuff
- counter := 0
- alphabet := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- fmt.Println("Started", start)
- letter1 = alphabet[start]
- for b := 0; b < len(alphabet); b++ {
- // stuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement