magic-crypt 4.0.1

MagicCrypt is a Java/PHP/NodeJS/Rust library to encrypt/decrypt strings, files, or data, using Data Encryption Standard(DES) or Advanced Encryption Standard(AES) algorithms. It supports CBC block cipher mode, PKCS7 padding and 64, 128, 192 or 256-bits key length.
Documentation
use core::convert::TryFrom;

/// How secure does your encryption need to be?
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SecureBit {
    Bit64,
    #[default]
    Bit128,
    Bit192,
    Bit256,
}

impl TryFrom<u16> for SecureBit {
    type Error = &'static str;

    #[inline]
    fn try_from(bit_number: u16) -> Result<Self, Self::Error> {
        Ok(match bit_number {
            64 => SecureBit::Bit64,
            128 => SecureBit::Bit128,
            192 => SecureBit::Bit192,
            256 => SecureBit::Bit256,
            _ => return Err("Unsupported number of bits."),
        })
    }
}