示例#1
0
        a = AuthenticatedCryptoAbstraction(bytes(self.dek, "utf-8"))
        #CT_AES = a.encrypt(message)
        return a.decrypt(CT)

    def on_log(self, client, userdata, level, buf):
        print("log: " + str(level) + ": " + str(buf));

if __name__ == '__main__':
    import sys, os
    
    sys.path.append(os.path.join(os.path.dirname(__file__), '../'))    
    from model.config import Config
    
    groupCfg = Config('../conf/gc_config.ini')
    
    sub = Subscriber(groupCfg.getConfig("mqtt_client"))
    sub.loop()

#    client = mqtt.Client()
#    client.on_connect = on_connect
#    client.on_message = on_message
#    client.on_log = on_log
    
    #ssh -N al@me -L 1883/localhost/1883
#    client.connect(cfg['host'], int(cfg['port']), int(cfg['keepalive']))
    #client.connect("localhost", 1883, 360)
    
    # Blocking call that processes network traffic, dispatches callbacks and
    # handles reconnecting.
    # Other loop*() functions are available that give a threaded interface and a
    # manual interface.
示例#2
0
    def encAES(self, m):
        if self.dek is None:
            raise Exception('DEK is null, cannot encrypt')

        a = AuthenticatedCryptoAbstraction(bytes(self.dek, "utf-8"))
        CT_AES = a.encrypt(m)
        groupObj = PairingGroup('SS512')

        return objectToBytes(CT_AES, groupObj)

    def loop_end(self):
        self._client.loop_stop();
        self._client.disconnect();
            
                                
if __name__ == '__main__':
    import sys, os

    sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
    from model.config import Config

    groupCfg = Config('../conf/gc_config.ini')
    cfg = groupCfg.getConfig("mqtt_client")
    cfg['topic'] = "test/topic"
    pub = Publisher(cfg)
    pub.loop();
    pub.publish("dude");
    pub.loop_end()