[Ethereum] How to use keccak256 in Solidity

hash-algorithmkeccaksha3solidity

I have created a Student registration form and taking input as firstName, lastName and studentRegId. Something like this:

contract Unique {

string fn;
string ln;
bytes20  val;
bytes32 sId;

function identify(string s, string y, bytes32 i)returns (bytes20){
    fn =s;
    ln =y;
    sId =i;
    val = keccak256(sm,bm,vm);
}

function getOut()constant returns (bytes20 ){
    return val;
}
}    

This should return a hash value (address). But it is showing the following error:

Untitled1:13:25: Error: Undeclared identifier.
    val = keccak256(sm,bm,vm); 

What should I do?

Best Answer

keccak256 is available in Solidity 0.4.3 and later.

If you're using browser-solidity, Solidity 0.4.4 and later is needed: keccak256 Error Undeclared identifier in browser-solidity