The encoding of a unsealed data into the replica data with a sector key is simple field additions. The Rust source is at https://github.com/filecoin-project/rust-fil-proofs/blob/fcb22da26b2ac6ea6acafd1da41cc4f098ae332b/storage-proofs-porep/src/encode.rs.
The following is a translation into a Python-like pseudo code, where I add the Go functions to call as comments.
def encode(key_bytes, value_bytes):
'''`key_bytes` and `value_bytes` are each 32 bytes long.