#NEWLINE# def encrypt( keyhex , noncehex ) : #NEWLINE# #INDENT# keybytes = from_hex ( keyhex . strip ( ) ) #NEWLINE# if noncehex : #NEWLINE# #INDENT# noncebytes = from_hex ( noncehex ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# noncebytes = nacl . utils . random ( nacl . secret . SecretBox . NONCE_SIZE ) #NEWLINE# #UNINDENT# secretbox = nacl . secret . SecretBox ( keybytes ) #NEWLINE# plainbytes = read_from_stdin ( ) #NEWLINE# cipherbytes = secretbox . encrypt ( plainbytes , noncebytes ) #NEWLINE# cipherhex = to_hex ( cipherbytes ) #NEWLINE# print_ ( cipherhex )