Last active
December 13, 2015 20:29
-
-
Save stephenjtong/4970583 to your computer and use it in GitHub Desktop.
字符串编码,解码使用dc -e密文P
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//decode result with dc command like dc -e0000P | |
import java.math.BigInteger; | |
public class DC_encode { | |
public static void main(String[] args) { | |
String a=""; | |
String b=args[0]+"\n"; | |
for(int i=0;i<b.length();i++){ | |
if(Integer.toBinaryString(b.charAt(i)).length()==8) | |
a=a+Integer.toBinaryString(b.charAt(i)); | |
else{ | |
for(int n=0;n<8-Integer.toBinaryString(b.charAt(i)).length();n++)//补位 | |
a=a+'0'; | |
a=a+Integer.toBinaryString(b.charAt(i)); | |
} | |
} | |
//System.out.println(a); | |
BigInteger bigInt = new BigInteger(a,2); | |
System.out.println(bigInt); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment