package pt.link.crypto;

public class SecurityElement {
	byte[] data;

	public SecurityElement(){
	}
	public SecurityElement(byte[] data){
		this.data = data;
	}
	public SecurityElement(String elementDataHex){
		this.data = CryptoUtils.hexStringToByteArray(elementDataHex);
	}
	
	public boolean equals(Object obj) {
		SecurityElement other = (SecurityElement) obj;
		if(this.data.length!=other.data.length){
			return false;
		}
		for(int i=0;i<this.data.length;i++){
			if(this.data[i]!=other.data[i])
				return false;
		}
		return true;
	}
	
	public String toString() {
		return CryptoUtils.stringArrayToString(CryptoUtils
				.toHexStringArray(this.data));
	}
	
	/**
	 * @return Returns the data.
	 */
	public byte[] getData() {
		return data;
	}

	/**
	 * @param data The data to set.
	 */
	public void setData(byte[] data) {
		this.data = data;
	}
	
	public static void main(String[] args) {
		SecurityElement s1 = new SecurityElement();
		byte b1[] = {1,2,3,4,5,6};
		s1.setData(b1);
		SecurityElement s2 = new SecurityElement();
		byte b2[] = {1,2,3,4,5,6};
		s2.setData(b2);
		System.out.println(s1.equals(s2));
	}
}
