Cryptography is a mathematical science which permits only the authorized users to access the data. Today, it is necessary for our routine life to safeguard online data like credit card numbers, bank transactions, etc. Many cryptographic algorithm-based data security mechanisms have been introduced by various researchers for protecting the online / M-Commerce data. Even though, no data security algorithms achieved the required security level with less time. For overcoming these issues, we propose a new data security algorithm called Elliptic-Curve Cryptography and Diffie-Hellman based data security algorithm for securing the M-Commerce data. Here, the key size of the Elliptic Curve Cryptography is less than RSA that will be helpful to improve the efficiency and reduce the storage space. This algorithm is able to establish a secure session key through a server over an insecure channel and also handle various illegitimate users. In addition, this new algorithm is more secure, efficient and suitable for mobile commerce environments than existing data security algorithms. For evaluating the data security mechanism, many experiments conducted with M-Commerce data that are collected from the Internet which are freely available and also proved the efficiency of the data security algorithm.