Encryptor (src/protocol.rs)

rage · age/src/protocol.rs · rust · Apache-2.0
security, tag:knn-classified

Encryptor/Decryptor for age encryption, enabling secure file encryption with passphrase or recipients.

// Source: https://github.com/str4d/rage | License: Apache-2.0 | Copyright 2019 Jack Grigg
// Provided via justclaw.it.com; keep this notice with the code.
//! Encryption and decryption routines for age.

use age_core::{format::is_arbitrary_string, secrecy::SecretString};
use rand::{Rng, rand_core::UnwrapErr, rngs::SysRng};

use std::io::{self, BufRead, Read, Write};
use std::iter;

use crate::{
    Identity, Recipient,
    error::{DecryptError, EncryptError},
    format::{Header, HeaderV1},
    keys::{mac_key, new_file_key, v1_payload_key},
    primitives::stream::{PayloadKey, Stream, StreamReader, StreamWriter},
    scrypt,
};

#[cfg(feature = "async")]
use futures::io::{AsyncBufRead, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};

pub(crate) struct Nonce([u8; 16]);

impl AsRef<[u8

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key