bluetoothNameAnonymizer function

Data bluetoothNameAnonymizer(
  1. Data data
)

A Bluetooth anonymizer function. Anonymizes the name and discovery name of each discovered bluetooth device. Bluetooth devices' names may contain participants' real name because people use their names to name their computers and phones.

Implementation

Data bluetoothNameAnonymizer(Data data) {
  assert(data is Bluetooth);
  Bluetooth bt = data as Bluetooth;
  for (var result in bt.scanResult) {
    result.bluetoothDeviceName =
        sha1.convert(utf8.encode(result.bluetoothDeviceName)).toString();
    result.advertisementName =
        sha1.convert(utf8.encode(result.advertisementName)).toString();
  }
  return bt;
}