kc

package
v16.6.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2020 License: MPL-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package kc provides functions for encoding/decoding darwin user passwords, for use in the /etc/kcpassword file. This is essentially a go port of http://www.brock-family.org/gavin/perl/kcpassword.html

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	MagicKey = []byte{0x7D, 0x89, 0x52, 0x23, 0xD2, 0xBC, 0xDD, 0xEA, 0xA3, 0xB9, 0x1F}
)

Functions

func AutoLoginPassword

func AutoLoginPassword() (password []byte, err error)

func AutoLoginUser

func AutoLoginUser() (user string, password []byte, err error)

func AutoLoginUsername

func AutoLoginUsername() (user string, err error)

func Decode

func Decode(encoded []byte) []byte
Example
package main

import (
	"fmt"

	"github.com/taskcluster/generic-worker/kc"
)

func main() {
	// Check case of no bytes after 0 byte terminator (password (12*n-1) bytes
	// for integer n, n > 0)
	fmt.Println(string(kc.Decode(kc.Encode([]byte("fredmary123")))))
	// Check case of trailing bytes after 0 byte terminator (password not
	// (12*n-1) bytes for integer n, n > 0)
	fmt.Println(string(kc.Decode(kc.Encode([]byte("fredmary1234")))))
}
Output:
fredmary123
fredmary1234

func Encode

func Encode(password []byte) []byte
Example
package main

import (
	"fmt"

	"github.com/taskcluster/generic-worker/kc"
)

func main() {
	fmt.Printf("%x\n", kc.Encode([]byte(`mysecretpassword`)))
	// 11 byte password should be 12 bytes when encoded
	fmt.Printf("%x\n", kc.Encode([]byte(`fredmary123`)))
	// 12 byte password should be 24 bytes when encoded (since encoded
	// passwords should always be a multiple of 12 bytes, but trailing
	// 0 byte is included in encoding, so 12 byte password is stored
	// as 13 bytes, meaning 24 bytes are needed not 12).
	fmt.Printf("%x\n", kc.Encode([]byte(`fredmary1234`)))
	fmt.Printf("%x\n", kc.Encode([]byte(`12345!@#$%{}PO"we[]{*&$!#+^ffdSWrhd4b#`)))
}
Output:
10f02146b1ceb89ed3d86c0efe3d51b6bcddeaa3b91f7d89
1bfb3747bfddaf93928b2c7d
1bfb3747bfddaf93928b2c49895223d2bcddeaa3b91f7d89
4cbb6117e79d9dc9879c6400d91d01a5d986b7d8933959a871088cdabb8ef0ee6d15ed6641f1bcddeaa3b91f7d895223

func LoginWindowPList

func LoginWindowPList() (data map[string]interface{}, err error)

func SetAutoLogin

func SetAutoLogin(user string, password []byte) (err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL