Securing Internet of Things (IoT) Devices Against MITM Attacks Through Algorithmic Measures