mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	godep restore pushd $GOPATH/src/github.com/appc/spec git co master popd go get go4.org/errorutil rm -rf Godeps godep save ./... git add vendor git add -f $(git ls-files --other vendor/) git co -- Godeps/LICENSES Godeps/.license_file_state Godeps/OWNERS
		
			
				
	
	
		
			31 lines
		
	
	
		
			579 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			579 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package auth
 | 
						|
 | 
						|
import "encoding/base64"
 | 
						|
import "crypto/md5"
 | 
						|
import "crypto/rand"
 | 
						|
import "fmt"
 | 
						|
 | 
						|
/*
 | 
						|
 Return a random 16-byte base64 alphabet string
 | 
						|
*/
 | 
						|
func RandomKey() string {
 | 
						|
	k := make([]byte, 12)
 | 
						|
	for bytes := 0; bytes < len(k); {
 | 
						|
		n, err := rand.Read(k[bytes:])
 | 
						|
		if err != nil {
 | 
						|
			panic("rand.Read() failed")
 | 
						|
		}
 | 
						|
		bytes += n
 | 
						|
	}
 | 
						|
	return base64.StdEncoding.EncodeToString(k)
 | 
						|
}
 | 
						|
 | 
						|
/*
 | 
						|
 H function for MD5 algorithm (returns a lower-case hex MD5 digest)
 | 
						|
*/
 | 
						|
func H(data string) string {
 | 
						|
	digest := md5.New()
 | 
						|
	digest.Write([]byte(data))
 | 
						|
	return fmt.Sprintf("%x", digest.Sum(nil))
 | 
						|
}
 |