Keep stored images encrypted
Browse files
API.md
CHANGED
|
@@ -79,4 +79,4 @@ POST /api/archive?p=PASSWORD
|
|
| 79 |
Content-Type: image/png
|
| 80 |
```
|
| 81 |
|
| 82 |
-
Stores the PNG in the current date's image directory without requesting a GPU.
|
|
|
|
| 79 |
Content-Type: image/png
|
| 80 |
```
|
| 81 |
|
| 82 |
+
Stores the PNG encrypted as `.epng` in the current date's image directory without requesting a GPU.
|
app.py
CHANGED
|
@@ -92,7 +92,7 @@ SALT_SIZE = 16
|
|
| 92 |
NONCE_SIZE = 12
|
| 93 |
SCRYPT_N = 2**14
|
| 94 |
FILE_MAGIC = b"EPNG1"
|
| 95 |
-
IMAGE_SUFFIXES = (".epng",
|
| 96 |
PREVIEW_QUALITY = 75
|
| 97 |
PREVIEW_SCALE = .25
|
| 98 |
DEFAULT_RETURN_SCALE = 1
|
|
@@ -1664,8 +1664,6 @@ def natural_key(path):
|
|
| 1664 |
|
| 1665 |
def stored_bytes(path):
|
| 1666 |
data = path.read_bytes()
|
| 1667 |
-
if path.suffix.casefold() == ".png":
|
| 1668 |
-
return data
|
| 1669 |
if not data.startswith(FILE_MAGIC):
|
| 1670 |
raise HTTPException(500, "invalid encrypted image")
|
| 1671 |
salt_start = len(FILE_MAGIC)
|
|
|
|
| 92 |
NONCE_SIZE = 12
|
| 93 |
SCRYPT_N = 2**14
|
| 94 |
FILE_MAGIC = b"EPNG1"
|
| 95 |
+
IMAGE_SUFFIXES = (".epng",)
|
| 96 |
PREVIEW_QUALITY = 75
|
| 97 |
PREVIEW_SCALE = .25
|
| 98 |
DEFAULT_RETURN_SCALE = 1
|
|
|
|
| 1664 |
|
| 1665 |
def stored_bytes(path):
|
| 1666 |
data = path.read_bytes()
|
|
|
|
|
|
|
| 1667 |
if not data.startswith(FILE_MAGIC):
|
| 1668 |
raise HTTPException(500, "invalid encrypted image")
|
| 1669 |
salt_start = len(FILE_MAGIC)
|