Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Argon2Config ¶
type Config ¶
type Config struct {
// ChunkSizeKB 定义了内容分块的平均大小(以 KB 为单位)。
ChunkSizeKB int `yaml:"chunk_size_kb"`
// DataShards 定义了纠删码所需的数据分片数。
DataShards int `yaml:"data_shards"`
// ParityShards 定义了纠删码所需的奇偶校验分片数。
ParityShards int `yaml:"parity_shards"`
// Argon2 包含了用于密钥派生的 Argon2 算法的配置。
Argon2 Argon2Config `yaml:"argon2"`
// StoragePath 定义了加密文件存储的根目录。
StoragePath string `yaml:"storage_path"`
}
func LoadConfig ¶
LoadConfig 从指定的路径加载 YAML 配置文件并解析它。 它返回一个包含配置的 Config 结构体指针,或者在出错时返回一个错误。
type EncryptionOptions ¶
type EncryptionOptions struct {
Password string
DataShards int
ParityShards int
ChunkSizeKB int
Argon2Time uint32
Argon2Memory uint32
Argon2Threads uint8
}
EncryptionOptions 封装了加密操作所需的所有参数。
type Manifest ¶
type Manifest struct {
Salt []byte `json:"salt"`
ChunkPaths []string `json:"chunk_paths"`
EncryptedOrigFilename []byte `json:"encrypted_orig_filename"`
EncryptedDataKeys [][]byte `json:"encrypted_data_keys"`
Argon2Time uint32 `json:"argon2_time"`
Argon2Memory uint32 `json:"argon2_memory"`
Argon2Threads uint8 `json:"argon2_threads"`
Signature []byte `json:"signature,omitempty"`
DataShards int `json:"data_shards"`
ParityShards int `json:"parity_shards"`
ErasureCodeChunkSuffixes [][]string `json:"erasure_code_chunk_suffixes"`
EncryptedChunkSizes []int `json:"encrypted_chunk_sizes"`
}
Manifest 结构体定义了加密文件的元数据,这些元数据以 JSON 格式存储在 manifest.json 文件中。 它包含了重建和解密文件所需的所有信息。
type SecureSyncer ¶
type SecureSyncer interface {
EncryptFile(localPath string, opts EncryptionOptions) (string, error)
DecryptFile(manifestID, outputPath, password string) error
}
SecureSyncer 定义了安全文件同步器的接口,提供了加密和解密文件的核心功能。
type Syncer ¶
type Syncer struct {
StorageDir string
}
Syncer 是 SecureSyncer 接口的具体实现。
func (*Syncer) DecryptFile ¶
DecryptFile 负责从存储中解密文件。
func (*Syncer) EncryptFile ¶
func (s *Syncer) EncryptFile(localPath string, opts EncryptionOptions) (manifestID string, err error)
EncryptFile 负责加密单个文件,并将其安全地存储到指定的目录中。
Click to show internal directories.
Click to hide internal directories.