kc

package
v48.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

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/taskcluster/v48/workers/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/taskcluster/v48/workers/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