Beispiel #1
0
    def decode(cls, decodable_string):
        key = config['gearman_key']

        padded_key = key.ljust(32, '\0')
        rij = Rijndael(padded_key)

        return rij.decrypt(b64decode(decodable_string))
Beispiel #2
0
def mkk(s, key):
    key_size = 32
    block_size = 16
    cipher = Rijndael(mbrpad(key, key_size), block_size=block_size)
    block = cipher.encrypt(mbrpad(s, block_size))
    qwords = QW(block)
    return '0x{:016x}'.format(qwords[0])
Beispiel #3
0
def mkk(s, key):
    key_size = 32
    block_size = 16
    cipher = Rijndael(mbrpad(key, key_size), block_size=block_size)
    block = cipher.encrypt(mbrpad(s, block_size))
    qwords = QW(block)
    return '0x{:016x}'.format(qwords[0])
Beispiel #4
0
def mkk(s, key):
    cipher = Rijndael(mbrpad(key), block_size=32)
    block = cipher.encrypt(mbrpad(s))
    print(hexlify(block))
    print(','.join('0x{:02x}'.format(b) for b in bytearray(block)))
    print('0x{:016x}, 0x{:016x}, 0x{:016x}, 0x{:016x}'.format(*QQW(block)))
    return block
Beispiel #5
0
    def __init__(self, key=None, padding=padWithPadLen(), keySize=16):
        """ Initialize AES, keySize is in bytes """
        if not (keySize == 16 or keySize == 24 or keySize == 32):
            raise BadKeySizeError, 'Illegal AES key size, must be 16, 24, or 32 bytes'

        Rijndael.__init__(self, key, padding=padding, keySize=keySize, blockSize=16)

        self.name = 'AES'
Beispiel #6
0
    def __init__(self, key = None, padding = padWithPadLen(), keySize=16):
        """ Initialize AES, keySize is in bytes """
        if  not (keySize == 16 or keySize == 24 or keySize == 32) :
            raise BadKeySizeError, 'Illegal AES key size, must be 16, 24, or 32 bytes'

        Rijndael.__init__( self, key, padding=padding, keySize=keySize, blockSize=16 )

        self.name       = 'AES'