behaviors.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:sshaolin 作者: bucknerns 项目源码 文件源码
def generate_ssh_keys(
        cls, size=4096, passphrase=None, private_format=PrivateFormat.PKCS8,
        public_format=PublicFormat.OpenSSH, private_encoding=Encoding.PEM,
            public_encoding=Encoding.OpenSSH):
        """Generates a public and private rsa ssh key

        Returns an SSHKeyResponse objects which has both the public and private
        key as attributes

        :param int size: RSA modulus length (must be a multiple of 256)
                             and >= 1024
        :param str passphrase: The pass phrase to derive the encryption key
                                from
        """
        encryption = (
            BestAvailableEncryption(passphrase) if passphrase else
            NoEncryption())
        key = rsa.generate_private_key(
            backend=default_backend(),
            public_exponent=65537,
            key_size=size)

        return SSHKey(
            public_key=key.public_key().public_bytes(
                public_encoding, public_format),
            private_key=key.private_bytes(
                Encoding.PEM, private_format, encryption))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号