Skip to content

Commit

Permalink
Use CSPRNG for judge keys
Browse files Browse the repository at this point in the history
  • Loading branch information
int-y1 authored and quantum5 committed Aug 26, 2021
1 parent bf3fbaf commit f14c877
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions judge/admin/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ def render(self, name, value, attrs=None, renderer=None):
<script type="text/javascript">
django.jQuery(document).ready(function ($) {{
$('#id_{0}_regen').click(function () {{
var length = 100,
charset = "abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`~!@#$%^&*()_+-=|[]{{}};:,<>./?",
key = "";
for (var i = 0, n = charset.length; i < length; ++i) {{
key += charset.charAt(Math.floor(Math.random() * n));
}}
var rand = new Uint8Array(75);
window.crypto.getRandomValues(rand);
var key = btoa(String.fromCharCode.apply(null, rand));
$('#id_{0}').val(key);
}});
}});
Expand Down

0 comments on commit f14c877

Please # to comment.