heat.common.password_gen 模块¶
- class heat.common.password_gen.CharClass(allowed_chars, min_count)¶
基类:
tuple- allowed_chars¶
字段编号 0 的别名
- min_count¶
字段编号 1 的别名
- heat.common.password_gen.generate_password(length, char_classes)[源代码]¶
生成随机密码。
密码的长度将为指定长度,并由指定的字符类组成,这些字符类可以使用
named_char_class()和special_char_class()函数生成。如果在字符类中指定了最小计数,则保证生成的密码中至少有该数量的字符来自该字符类。- 参数:
length – 要生成的密码的长度,以字符为单位
char_classes – 可迭代对象,包含用于生成密码的字符类
- heat.common.password_gen.named_char_class(char_class, min_count=0)[源代码]¶
返回预定义的字符类。
此函数的结果可以作为要使用的字符类之一传递给
generate_password(),用于生成密码。- 参数:
char_class –
CHARACTER_CLASSES中命名的字符类中的任何一个min_count – 密码中此类的成员的最小数量
- heat.common.password_gen.special_char_class(allowed_chars, min_count=0)[源代码]¶
返回包含自定义字符的字符类。
此函数的结果可以作为要使用的字符类之一传递给
generate_password(),用于生成密码。- 参数:
allowed_chars – 字符类中字符的可迭代对象
min_count – 密码中此类的成员的最小数量