textMessageAnoymizer function Null safety

TextMessage textMessageAnoymizer(
  1. TextMessage msg
)

A TextMessage anonymizer function. Anonymizes:

  • address
  • body

Implementation

TextMessage textMessageAnoymizer(TextMessage msg) {
  if (msg.address != null)
    msg.address = sha1.convert(utf8.encode(msg.address!)).toString();
  if (msg.body != null)
    msg.body = sha1.convert(utf8.encode(msg.body!)).toString();

  return msg;
}