Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
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')
Beispiel #4
0
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') 
Beispiel #5
0
def make_jwt(userid):
    cryptokey = get_cryptokey()
    encoded = jwt.encode({'user': userid}, cryptokey, algorithm='HS256')
    return encoded
Beispiel #6
0
def decode_jwt(token):
    cryptokey = get_cryptokey()
    decoded = jwt.decode(token, cryptokey, algorithm='HS256')
    return decoded['user']
Beispiel #7
0
def decode_jwt(token):
	cryptokey = get_cryptokey()
	decoded = jwt.decode(token,cryptokey, algorithm='HS256')
	return decoded['user']
Beispiel #8
0
def make_jwt(userid):
	cryptokey = get_cryptokey()
	encoded = jwt.encode({'user': userid}, cryptokey, algorithm='HS256')
	return encoded
Beispiel #9
0
    def _make_page(self, the_user):

        template_args = {'current': crypto_db.get_cryptokey()}
        self.render_template('crypto_admin.html', template_args)
Beispiel #10
0
 def _make_page(self,the_user):
 
     template_args = {
         'current' : crypto_db.get_cryptokey()
     }
     self.render_template('crypto_admin.html', template_args)