Skip to content
views.py 34.9 KiB
Newer Older
        raise PermissionDenied(_("only staff may use this tool"))

    from paramiko import RSAKey
    key_class = RSAKey
    prv = key_class.generate(bits=2048)

    import six
    prv_bio = six.BytesIO()
    prv.write_private_key(prv_bio)

    prv_bio_read = six.BytesIO(prv_bio.getvalue())

    pub = key_class.from_private_key(prv_bio_read)

    pub_bio = six.BytesIO()
    pub_bio.write("%s %s relate-course-key" % (pub.get_name(), pub.get_base64()))

    return render(request, "course/keypair.html", {
        "public_key": prv_bio.getvalue().decode(),
        "private_key": pub_bio.getvalue().decode(),
        })

# }}}


# vim: foldmethod=marker