// use pgp::composed::{key::SecretKeyParamsBuilder, KeyDetails, KeyType, SecretKey, SecretSubkey};
// use pgp::packet::{KeyFlags, UserAttribute, UserId};
// use pgp::types::{CompressionAlgorithm, PublicKeyTrait, SecretKeyTrait};
use pgp::composed::{key::SecretKeyParamsBuilder, KeyType};
use pgp::crypto::{hash::HashAlgorithm, sym::SymmetricKeyAlgorithm};
use pgp::types::{CompressionAlgorithm, SecretKeyTrait};
use smallvec::*;

fn main() {
    let mut key_params = SecretKeyParamsBuilder::default();
    key_params
        .key_type(KeyType::Rsa(2048))
        .can_create_certificates(false)
        .can_sign(true)
        .primary_user_id("Me <me@example.com>".into())
        .preferred_symmetric_algorithms(smallvec![
        SymmetricKeyAlgorithm::AES256,
    ])
        .preferred_hash_algorithms(smallvec![
        HashAlgorithm::SHA2_256,
    ])
        .preferred_compression_algorithms(smallvec![
        CompressionAlgorithm::ZLIB,
    ]);
    let secret_key_params = key_params.build().expect("Must be able to create secret key params");
    let secret_key = secret_key_params.generate().expect("Failed to generate a plain key.");
    let passwd_fn = || String::new();
    let signed_secret_key = secret_key.sign(passwd_fn).expect("Must be able to sign its own metadata");
    let public_key = signed_secret_key.public_key();

    // println!("{:?}", secret_key);
    println!("{:?}", signed_secret_key);
    println!("{:?}", public_key);
}
