You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+112-32
Original file line number
Diff line number
Diff line change
@@ -11,55 +11,134 @@ It uses [zeroize](https://crates.io/crates/zeroize) crate under the hood.
11
11
It can work with `bytearray` and `numpy array`.
12
12
13
13
> [!WARNING]
14
-
> **Currently it doens't work in the case of [Copy-on-write fork](https://en.wikipedia.org/wiki/Copy-on-write), you can follow this [issue](https://github.com/radumarias/zeroize-python/issues/1)
15
-
> Also by itself it doesn't work if memory is moved or moved to swap file. You can use `crypes` with `libc.mlockall()` to lock the memory, see example below.**
14
+
> **In the case of [Copy-on-write fork](https://en.wikipedia.org/wiki/Copy-on-write) you should zeroize the memory before fork the child process, see example below.
15
+
> Also by itself it doesn't work if memory is moved or moved to swap file. You can use `crypes` with `libc.mlock()` to lock the memory, see example below.**
16
16
17
-
# Example
17
+
# Examples
18
+
19
+
## Lock and zeroize memory
18
20
19
21
```python
20
-
import zeroize
22
+
from zeroizeimport zeroize1, zeroize_np
21
23
import numpy as np
22
24
import ctypes
23
25
24
26
25
-
# Lock memory using ctypes
26
-
deflock_memory():
27
-
libc = ctypes.CDLL("libc.so.6")
28
-
# Lock all current and future pages from being swapped out
This mitigates the problems that appears on [Copy-on-write fork](https://en.wikipedia.org/wiki/Copy-on-write). You need to zeroize the data before forking the child process.
0 commit comments