Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package it.crypt;
- import java.io.UnsupportedEncodingException;
- public class Test {
- public static void main(String[] args) throws UnsupportedEncodingException{
- byte[] bytes = "porcoddio".getBytes();
- StringBuilder binary = new StringBuilder();
- for (byte b : bytes){
- int val = b;
- for (int i = 0; i < 8; i++){
- binary.append((val & 128) == 0 ? 0 : 1);
- val <<= 1;
- }
- }
- String test = binary.toString();
- String[] ara = test.split("(?<=\\G...)");
- //System.out.println(ara[0]);
- Integer[] intarray=new Integer[ara.length];
- int i=0;
- for(String str:ara){
- intarray[i]=Integer.parseInt(str.trim());
- i++;
- }
- i = 0;
- Boolean vergine = true;
- String all = null;
- for(int in = 0; in <intarray.length; in++){
- if(vergine==true){vergine=false; all = Integer.toString(convert(intarray[in]));}
- all = all + Integer.toString(convert(intarray[in]));
- }
- System.out.println(hexcvn(Integer.parseInt(all)));
- }
- public static int convert(int n) {
- return Integer.valueOf(String.valueOf(n), 16);
- }
- public static String hexcvn(int hex){
- String hexd = "17172560272273257272161702722722732572562561710272256257257273"; //Integer.toString(hex);
- StringBuilder output = new StringBuilder();
- for (int i = 0; i < hexd.length(); i+=2) {
- String str = hexd.substring(i, i+2);
- output.append((char)Integer.parseInt(str, 16));
- }
- return output.toString();
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement