You can construct a counter-mode cipher using SHA256 as a primitive if you really want to. 

```
from hashlib import sha256
import numpy as np

def mask(rank):
    # Since we will be converting to/from bytes, endianness is important.
    uint32be = np.dtype('>u4')
    x = np.empty([624 // 8, 2], dtype=uint32be)
    # The hash of the rank catted with an increasing index (stuffed into big-endian uint32s) are hashed
    # with SHA-256 to make the XOR mask for 8 consecutive uint32 words for a 624-word Mersenne
    # Twister state.
    x[:, 0] = rank
    x[:, 1] = np.arange(624 // 8)
    mask_buffer = b''.join(sha256(row).digest() for row in x)
    # And convert back to native-endian.
    mask = np.frombuffer(mask_buffer, dtype=uint32be).astype(np.uint32)
    return mask
```