commit 7c25607f33fb88eed1203c4aba2162dda66f894f Author: Minecon724 Date: Fri Jun 28 14:59:00 2024 +0200 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..bdc44ab --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +### Generating a file + +1. `head -c 8 myfile` +2. `head -c 16M >myfile` + +You can repeat the second command to grow the file \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..69e1224 --- /dev/null +++ b/main.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass +from io import BufferedRandom + +@dataclass +class Shard: + size: int + file: BufferedRandom + + @staticmethod + def load_shard(filename: str) -> 'Shard': + file = open(filename, 'rb+') + size = int.from_bytes(file.read(8), 'big') + + return Shard(size, file) + +@dataclass +class Entry: + shard: Shard + + content: bytearray + + + +shart = Shard.load_shard('myfile') +print(shart.size) \ No newline at end of file diff --git a/myfile b/myfile new file mode 100644 index 0000000..98222a1 Binary files /dev/null and b/myfile differ diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..a6fbfad --- /dev/null +++ b/notes.txt @@ -0,0 +1,16 @@ +the idea: +there's one big file (diary) +its size is set on creation and constant +its filled with random data +the file begins with a long which is total length of the diary, encrypt +inside it there are entries: +- timestamp +- start index of previous entry (encrypted of course) +- length of data +- data +you can't edit data if there's a newer entry +each entry is encrypted + +there's also an index file: +- total length of diary +- \ No newline at end of file