def decrypt_string(the_string): key = crypto_db.get_cryptokey() ciphertext = binascii.unhexlify(the_string) decobj = AES.new(key, AES.MODE_ECB) plaintext = decobj.decrypt(ciphertext) # Resulting plaintext return plaintext
def encrypt_string(the_string): key = crypto_db.get_cryptokey() encobj = AES.new(key, AES.MODE_ECB) # pad out the string to a multiple of 16 x = 16 - (len(the_string) % 16) if x < 16: the_string_pad = '{: <{}}'.format(the_string, len(the_string) + x) else: the_string_pad = the_string ciphertext = encobj.encrypt(the_string_pad) # Resulting ciphertext in hex return ciphertext.encode('hex')
def encrypt_string(the_string): key = crypto_db.get_cryptokey() encobj = AES.new(key, AES.MODE_ECB) # pad out the string to a multiple of 16 x = 16-(len(the_string) % 16) if x < 16: the_string_pad = '{: <{}}'.format(the_string,len(the_string)+x) else: the_string_pad = the_string ciphertext = encobj.encrypt(the_string_pad) # Resulting ciphertext in hex return ciphertext.encode('hex')
def make_jwt(userid): cryptokey = get_cryptokey() encoded = jwt.encode({'user': userid}, cryptokey, algorithm='HS256') return encoded
def decode_jwt(token): cryptokey = get_cryptokey() decoded = jwt.decode(token, cryptokey, algorithm='HS256') return decoded['user']
def decode_jwt(token): cryptokey = get_cryptokey() decoded = jwt.decode(token,cryptokey, algorithm='HS256') return decoded['user']
def _make_page(self, the_user): template_args = {'current': crypto_db.get_cryptokey()} self.render_template('crypto_admin.html', template_args)
def _make_page(self,the_user): template_args = { 'current' : crypto_db.get_cryptokey() } self.render_template('crypto_admin.html', template_args)