-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrypto.hpp
More file actions
34 lines (28 loc) · 1.03 KB
/
Copy pathcrypto.hpp
File metadata and controls
34 lines (28 loc) · 1.03 KB
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
31
32
33
34
#pragma once
#include <cstdint>
#include <cstddef>
#include <string>
#include <vector>
#include <array>
namespace sflk {
struct Meta {
uint32_t iterations = 200000;
std::vector<uint8_t> salt; // 16B
std::vector<uint8_t> iv; // 12B
std::string origName; // UTF-8
uint64_t origSize = 0;
std::array<uint8_t,32> sha256{}; // plaintext checksum
};
std::vector<uint8_t> derive_key(const std::string& password,
const std::vector<uint8_t>& salt,
uint32_t iterations);
void encrypt_file(const std::string& inPath,
const std::string& outPath,
const std::string& password,
uint32_t iterations = 200000);
std::string decrypt_file(const std::string& inPath,
const std::string& outPath,
const std::string& password);
Meta read_header(const std::string& inPath);
void verify_file(const std::string& inPath, const std::string& password);
} // namespace sflk