搞定了:
public class password 
{
public static void main(String[] args) 
{
        String LcPassword = "12345";
try
{
byte temp[] = LcPassword.getBytes("gb2312");
for (int i=0;i<LcPassword.length() ;i++ )
{
temp[i] = (byte)(255 - (i+1) - (int)temp[i]);
}
//System.out.println(tempPassword);
LcPassword=new String(temp, 0, temp.length, "gb2312").trim();
}
catch (Exception Ue)
{
             Ue.printStackTrace();
}
}
}
大家有没有更好的方法,都说说吧

解决方案 »

  1.   

    try
    {
    char temp[] = LcPassword.toCharArray()          for (int i=0;i<LcPassword.length() ;i++ )
    {
    temp[i] = (char)(255-temp[i]);
    }
    //System.out.println(tempPassword);
    LcPassword=new String(temp, 0, temp.length, "gb2312").trim();
    }
    catch (Exception Ue)
    {
                 Ue.printStackTrace();
    }
      

  2.   

    上面的应该是
    LcPassword=new String((byte)temp, 0, temp.length, "gb2312").trim();
    我的那个方法更正:
    temp[i] = (byte)(255 - (int)temp[i]);