When a host request a page from server, the server will 1st bind a encryption key to the host's mac address. Data provided by host will be encrypted at the client side using the same encryption key. The encrypted data submitted by the host will be decrypt by the server. This is what i am trying to do.

I would like to know how do i get the mac address of a requesting host?

I am not familiar with asp.net. How should i encrypt the data at client side? Should i use client side scripting like javascript or is there an alternative for me to do it using C#?

You don't want to use the MAC address.

The MAC layer addressing mechanism is called physical address or MAC address. This is a unique serial number assigned to each network adapter, making it possible to deliver data packets to a destination within a subnetwork, i.e. a physical network consisting of one or several network segments interconnected by repeaters, hubs, bridges and switches, but not by IP routers. An IP router may interconnect several subnets.

http://en.wikipedia.org/wiki/Media_Access_Control
Also see: http://en.wikipedia.org/wiki/Network_Layer

The browser will need to support whatever encryption you implement. So unless you want to write browser plugins you should use technology already available (http/ssl aka https) and go that route.

The following code will help you to get the MAC address of client PC using JavaScript.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting MAC Address From Javascript(IE Only)</title>
 
<script language="javascript">
function showMacAddress(){
 
	var obj = new ActiveXObject("WbemScripting.SWbemLocator");
	var s = obj.ConnectServer(".");
	var properties = s.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
	var e = new Enumerator (properties);

 
	var output;
	output='<table border="0" cellPadding="5px" cellSpacing="1px" bgColor="#CCCCCC">';
	output=output + '<tr bgColor="#EAEAEA"><td>Caption</td><td>MACAddress</td></tr>';
	while(!e.atEnd())

	{
		e.moveNext();
		var p = e.item ();
		if(!p) continue;
		output=output + '<tr bgColor="#FFFFFF">';
		output=output + '<td>' + p.Caption; + '</td>';
		output=output + '<td>' + p.MACAddress + '</td>';
		output=output + '</tr>';
	}

	output=output + '</table>';
	document.getElementById("box").innerHTML=output;
}
</script>
 
</head>
<body>
	<input type="button" value="Show MAC Address" onclick="showMacAddress()" />

	<div id="box">
	</div>
</body>
</html>

Reference: http://www.eggheadcafe.com/community/aspnet/3/10054387/client-mac-address.aspx

But the above code will work in IE only. Also you need to enable ActiveX component in your browser settings.

For encryption of the data at client side, you need to use javascript. Since code is rendered at client browser, your encryption logic can be visible to the end user.

Besides what i said in the 1st post... Is there any alternative to secure the data from host/client host that are going to server side?

Use https like the rest of the world?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.