def TemporaryHmacSecretFile( secret ): """Helper function for passing the hmac secret when starting a JediHTTP server with TemporaryHmacSecretFile( 'mysecret' ) as hmac_file: jedihttp = subprocess.Popen( ['python', 'jedihttp', '--hmac-file-secret', hmac_file.name ] ) The JediHTTP Server as soon as it reads the hmac secret will remove the file """ hmac_file = tempfile.NamedTemporaryFile( 'w', delete = False ) encoded_secret = decode_string( b64encode( encode_string( secret ) ) ) json.dump( { 'hmac_secret': encoded_secret }, hmac_file ) return hmac_file
def TemporaryHmacSecretFile(secret): """Helper function for passing the hmac secret when starting a JediHTTP server with TemporaryHmacSecretFile( 'mysecret' ) as hmac_file: jedihttp = subprocess.Popen( ['python', 'jedihttp', '--hmac-file-secret', hmac_file.name ] ) The JediHTTP Server as soon as it reads the hmac secret will remove the file """ hmac_file = tempfile.NamedTemporaryFile('w', delete=False) encoded_secret = decode_string(b64encode(encode_string(secret))) json.dump({'hmac_secret': encoded_secret}, hmac_file) return hmac_file
def _hmac(self, content): return hmac.new(self._secret, msg=encode_string(content), digestmod=hashlib.sha256).digest()
def __init__(self, secret): self._secret = encode_string(secret)
def _Hmac( self, content ): return hmac.new( self._secret, msg = encode_string( content ), digestmod = hashlib.sha256 ).digest()
def __init__( self, secret ): self._secret = encode_string( secret )