initial commit

This commit is contained in:
Minecon724 2024-06-28 14:59:00 +02:00
commit 7c25607f33
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
4 changed files with 47 additions and 0 deletions

6
README.md Normal file
View file

@ -0,0 +1,6 @@
### Generating a file
1. `head -c 8 </dev/zero >myfile`
2. `head -c 16M </dev/random >>myfile`
You can repeat the second command to grow the file

25
main.py Normal file
View file

@ -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)

BIN
myfile Normal file

Binary file not shown.

16
notes.txt Normal file
View file

@ -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
-