#[allow(unused)]
#[derive(Debug, Default)]
pub enum PasswordType {
Legacy, #[default]
Distinct, Emoji, }
impl PasswordType {
#[inline]
pub(crate) fn get_char(&self, index: usize) -> Option<char> {
match &self {
PasswordType::Legacy => LEGACY_BYTES
.get(index)
.map_or(None, |&v| char::from_u32(v as u32)),
PasswordType::Distinct => DISTINCT_BYTES
.get(index)
.map_or(None, |&v| char::from_u32(v as u32)),
PasswordType::Emoji => EMOJI_CHARS.get(index).copied(),
}
}
}
const LEGACY_BYTES: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const DISTINCT_BYTES: &[u8; 64] =
b"@#$%&*123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
const EMOJI_CHARS: &[char; 64] = &[
'😊', '😍', '😛', '😭', '😎', '👽', '💀', '👻',
'✋', '👌', '👉', '👍', '❤', '💋', '🙏', '💪',
'🐵', '🐶', '🐴', '🐷', '🐔', '🐸', '🐍', '🐬',
'🌻', '🌷', '🌱', '🌴', '🌵', '🍀', '🍄', '🍒',
'🍔', '🍟', '🍕', '🍦', '🍺', '🍉', '🍌', '🍎',
'🏠', '⏰', '💊', '☕', '🚗', '🚲', '✈', '🚀',
'☀', '🌙', '⭐', '⚡', '☔', '🌈', '🔥', '💧',
'🎄', '🎁', '🎈', '🎉', '🔔', '🏆', '🔒', '🔑',
];