Skip to content

Encrypted device communication

You can enable encrypted communication with your IoTize device. It's recommended if you are not using secure protocol.

import { IoTizeDevice }  from '@iotize/device-client.js/device';

let device: IoTizeDevice = ...; // your device

try{
    await device.enableEncryption(true);

    // Now all requests will be enrypted
    let response = await device
        .service
        .getSerialNumber();

    // Once your are done your can stop encryption
    await device.enableEncryption(false);
}
catch (err){
    // Error cannot enable encryption
    // It may happen for exemple if your device is not connected...
}
import com.iotize.android.device.device.impl.IoTizeDevice;

// ...
IoTizeDevice device = ...; // your device

// Enable encryption (it may throw an error)
device.enableEncryption(true);

// Now all requests will be encrypted
// Use your device object as usuall
String serialNumber = device.service.device.getSerialNumber().get();
// ...

// Once your are done your can stop encryption
device.enableEncryption(false);