kc

package
v15.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: MPL-2.0 Imports: 6 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/generic-worker/kc"
)

func main() {
	// Check case of no null byte terminator (password multiple of 11 bytes)
	fmt.Println(string(kc.Decode(kc.Encode([]byte("fredmary123")))))
	// Check case of null byte terminator (password not multiple of 11 bytes)
	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 11 bytes when encoded
	fmt.Printf("%x\n", kc.Encode([]byte(`fredmary123`)))
	// 12 byte password should be 22 bytes when encoded (since encoded
	// passwords should always be a multiple of 11 bytes)
	fmt.Printf("%x\n", kc.Encode([]byte(`fredmary1234`)))
	fmt.Printf("%x\n", kc.Encode([]byte(`12345!@#$%{}PO"we[]{*&$!#+^ffdSWrhd4b#`)))
}
Output:

10f02146b1ceb89ed3d86c0efe3d51b6bcddeaa3b91f
1bfb3747bfddaf93928b2c
1bfb3747bfddaf93928b2c49895223d2bcddeaa3b91f
4cbb6117e79d9dc9879c6400d91d01a5d986b7d8933959a871088cdabb8ef0ee6d15ed6641f1bcddeaa3b91f

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