File: math3.go

package info (click to toggle)
golang-github-traefik-yaegi 0.16.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 24,608 kB
  • sloc: sh: 457; makefile: 39
file content (32 lines) | stat: -rw-r--r-- 499 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main

import (
	"crypto/md5"
	"fmt"
)

func md5Crypt(password, salt, magic []byte) []byte {
	d := md5.New()
	d.Write(password)
	d.Write(magic)
	d.Write(salt)

	d2 := md5.New()
	d2.Write(password)
	d2.Write(salt)

	for i, mixin := 0, d2.Sum(nil); i < len(password); i++ {
		d.Write([]byte{mixin[i%16]})
	}

	return d.Sum(nil)
}

func main() {
	b := md5Crypt([]byte("1"), []byte("2"), []byte("3"))

	fmt.Println(b)
}

// Output:
// [187 141 73 89 101 229 33 106 226 63 117 234 117 149 230 21]