MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / encrypt_segment

Function encrypt_segment

nodedb-array/src/segment/encrypt.rs:27–36  ·  view source on GitHub ↗

Encrypt `plaintext` (a complete plaintext segment buffer) and return the SEGA envelope.

(
    key: &WalEncryptionKey,
    plaintext: &[u8],
)

Source from the content-addressed store, hash-verified

25/// Encrypt `plaintext` (a complete plaintext segment buffer) and return the
26/// SEGA envelope.
27pub(crate) fn encrypt_segment(
28 key: &WalEncryptionKey,
29 plaintext: &[u8],
30) -> Result<Vec<u8>, ArrayError> {
31 encrypt_segment_envelope(key, &SEGA_MAGIC, plaintext).map_err(|e| {
32 ArrayError::EncryptionFailed {
33 detail: e.to_string(),
34 }
35 })
36}
37
38/// Decrypt an encrypted array segment blob (starting at byte 0 = `SEGA`).
39///

Calls 2

encrypt_segment_envelopeFunction · 0.85
to_stringMethod · 0.80