生成给定模式的随机字符串
funny-codes的Python项目详细描述
这是一个小模块,用于生成给定模式的随机字符串。 它还能够估计此模式的各种度量 (碰撞概率、估计的碰撞计数和总变量计数)。
安装
$ pip install funny-codes
用法
>>> from funny_codes import FunnyCodes >>> my_codes = FunnyCodes('TATAN-76') >>> my_codes.next() # the following is a random code matching the pattern HIPAS-12 >>> my_codes.next() MOVER-87 >>> my_codes.variants_count() 20000844 >>> my_codes.collision_prob(1000) 0.024664677603280283 >>> my_codes.expected_collisions(10000) 2.499235797673464