One-time pad: Difference between revisions

→‎Python: I didn't realize it was better to use multiple lines of import statements rather than comma-separated import statements. I am changing this back to import on different lines based on a suggestion from PyCharm Professional.
m (syntax highlighting fixup automation)
imported>EliteSuperiorIntelligenceSocialStandingWealthPowerfulRichGiftedEducatedUpperClassUpperCrustCrèmedelaCrème
(→‎Python: I didn't realize it was better to use multiple lines of import statements rather than comma-separated import statements. I am changing this back to import on different lines based on a suggestion from PyCharm Professional.)
 
(4 intermediate revisions by 2 users not shown)
Line 1,467:
import secrets
import sys
 
 
# One-time pad file signature.
Line 1,476 ⟶ 1,475:
"""Generate ``n`` secure, random keys of ``size`` bytes."""
# We're generating and storing keys in their hexadecimal form to make
# one-time pad files a little more human -readable and to ensure a key
# can not start with a hyphen.
return (secrets.token_hex(size) for _ in range(n))
Line 1,549 ⟶ 1,548:
Args:
path (pathlib.Path): Path to write one-time pad to.
lengthpad_size (int): NumberThe number of keys (or pages) in the pad.
key_size (int): The number of bytes per key.
"""
if path.exists():
Line 1,955:
{{libheader|Wren-dynamic}}
{{libheader|Wren-str}}
<syntaxhighlight lang="ecmascriptwren">import "io" for File, Directory
import "./srandom" for SRandom
import "./ioutil" for FileUtil, Input
import "./dynamic" for Enum
import "./str" for Char, Str
 
var CHARS_PER_LINE = 48