/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package communication;

import hash.hashUtil;
import mdot.Main;
import structures.Constants;

/**
 *class Serialize
 *Creates the string that will be sent to neighbor vechiles.
 *String contains all information needed to reconstruct the vehicle's hash table
 *at the receiving vehicle. The hash value of the string is calculated and
 *appended to the front of the string.
 */
public class Serialize {


    public static String serializeHashContext(){
        String serializedString =   Main.meString+
                                    Constants.DELIMITER_FOR_VIN+
                                    Main.password+
                                    Constants.DELIMITER_FOR_VIN+
                                    Main.portno_receive+
                                    Constants.DELIMITER_FOR_VIN+
                                    Main.getMe().toString();

        String hash = String.valueOf(hashUtil.getHash(serializedString));
        serializedString = hash +Constants.DELIMITER_FOR_HASHCODE + serializedString;

        return serializedString;
    }
}
