github.com/HaHadaxigua/yaegi@v1.0.1/_test/math3.go (about)

     1  package main
     2  
     3  import (
     4  	"crypto/md5"
     5  	"fmt"
     6  )
     7  
     8  func md5Crypt(password, salt, magic []byte) []byte {
     9  	d := md5.New()
    10  	d.Write(password)
    11  	d.Write(magic)
    12  	d.Write(salt)
    13  
    14  	d2 := md5.New()
    15  	d2.Write(password)
    16  	d2.Write(salt)
    17  
    18  	for i, mixin := 0, d2.Sum(nil); i < len(password); i++ {
    19  		d.Write([]byte{mixin[i%16]})
    20  	}
    21  
    22  	return d.Sum(nil)
    23  }
    24  
    25  func main() {
    26  	b := md5Crypt([]byte("1"), []byte("2"), []byte("3"))
    27  
    28  	fmt.Println(b)
    29  }
    30  
    31  // Output:
    32  // [187 141 73 89 101 229 33 106 226 63 117 234 117 149 230 21]