package client;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class user implements Serializable{
private static int count;
private String name;
private transient String password;
public user(String name,String password){
this.name = name;
this.password = password;
}
//数据加密函数
private byte[] change(byte[] buff){
for(int i=0; i<buff.length;i++){
int b = 0;
for(int j=0; j<8;j++){
int bit = (buff[i] >> j & 1) == 1?0:1;
b += (1<<j)*bit;
}
buff[i] = (byte)b;
}
return buff;
}
private void writeObject(ObjectOutputStream stream)throws
IOException{
stream.defaultWriteObject();
stream.writeObject(change(password.getBytes()));
stream.writeInt(count);
}
private void readObject(ObjectInputStream stream)throws
IOException,ClassNotFoundException{
stream.defaultReadObject();
byte[] buff = (byte[])stream.readObject();
password = new String(change(buff));
count = stream.readInt();
}
public String toString(){
return name + " " +password;
}
}