aboutsummaryrefslogtreecommitdiff
path: root/info.go
blob: 1ac903449494d60e708220e53b6ebbddf9e26a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/rfjakob/gocryptfs/v2/internal/configfile"
	"github.com/rfjakob/gocryptfs/v2/internal/exitcodes"
)

// info pretty-prints the contents of the config file at "filename" for human
// consumption, stripping out sensitive data.
// This is called when you pass the "-info" option.
func info(filename string) {
	cf, err := configfile.Load(filename)
	if err != nil {
		fmt.Printf("Loading config file failed: %v\n", err)
		os.Exit(exitcodes.LoadConf)
	}
	s := cf.ScryptObject
	algo, _ := cf.ContentEncryption()
	// Pretty-print
	fmt.Printf("Creator:           %s\n", cf.Creator)
	fmt.Printf("FeatureFlags:      %s\n", strings.Join(cf.FeatureFlags, " "))
	fmt.Printf("EncryptedKey:      %dB\n", len(cf.EncryptedKey))
	fmt.Printf("ScryptObject:      Salt=%dB N=%d R=%d P=%d KeyLen=%d\n",
		len(s.Salt), s.N, s.R, s.P, s.KeyLen)
	fmt.Printf("contentEncryption: %s\n", algo.Algo) // lowercase because not in JSON
}