//从字符串(ASCII)到二进制
public static String stringToBinary(String str) {
StringBuffer str2=new StringBuffer();
for(int i=0;i
str2=str2.append(fill_zero(Integer.toBinaryString(Integer.valueOf(str.charAt(i))),8));
}
return str2.toString();
}
//按位填充函数
public static String fill_zero(String str,int n) {
String str2=new String();
StringBuffer str1=new StringBuffer();
if(str.length()
for(int i=0;i
str2=str1.append('0').toString();
}
return str2+str;//Integer.toHexString(Integer.valueOf(str2+s,2))+" ";//换成十六进制;
}
//按位异或
public static String bit_df_or(String str1,String str2) {
String str=new String();
StringBuffer s=new StringBuffer();
for(int i=0;i
if(str1.charAt(i)==str2.charAt(i))
str=s.append('0').toString();
else
str=s.append('1').toString();
}
return str;
}
//按位同或
public static String bit_sa_or(String str1,String str2) {
String str=new String();
StringBuffer s=new StringBuffer();
for(int i=0;i
if(str1.charAt(i)==str2.charAt(i))
str=s.append('1').toString();
else
str=s.append('0').toString();
}
return str;
}
//按位与