//string to 8wei ascii
private String stringToAscii(String regmsg) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
char[] chars = regmsg.toCharArray();
String asciiMsg = "";
String bawei = "";
for (int i = 0; i < chars.length; i++) {
String c = "";
int a = (int) chars[i];
String baweiString = "" + Integer.toBinaryString(a);
if (baweiString.length() < 8) {
int length = 8 - baweiString.length();
for (int j = 0; j < length; j++) {
c = c + "0";
}
bawei = c + baweiString;
} else {
}
asciiMsg += bawei;
}
System.out.println("asciiMsg" + asciiMsg);
return asciiMsg;
}
private String stringToAscii(String regmsg) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
char[] chars = regmsg.toCharArray();
String asciiMsg = "";
String bawei = "";
for (int i = 0; i < chars.length; i++) {
String c = "";
int a = (int) chars[i];
String baweiString = "" + Integer.toBinaryString(a);
if (baweiString.length() < 8) {
int length = 8 - baweiString.length();
for (int j = 0; j < length; j++) {
c = c + "0";
}
bawei = c + baweiString;
} else {
}
asciiMsg += bawei;
}
System.out.println("asciiMsg" + asciiMsg);
return asciiMsg;
}