The "ink" of a sea hare is thought to be a defensive/distractive
measure, just like that of an octopus. The animal makes the ink by
partially metabolizing red pigments from red algae which they eat. If
you keep a sea hare in captivity and feed it only green algae, it can no
longer produce the "ink". The red/purple secretion is not considered
noxious, but some sea hares can secrete an additional whitish substance
which is fairly noxious.
Paul M.