package com.terra.proxy.util;
|
|
public class CrpUtil {
|
|
|
private static char[] codes={'a','b','c','d','e','f','g','h','i','j','h'};
|
|
|
public static String encode(Integer num){
|
String temp= num.toString();
|
char[] b=temp.toCharArray();
|
StringBuilder sb=new StringBuilder();
|
for (int i = 0; i < b.length; i++) {
|
int t= b[i]-'0';
|
sb.append(codes[t]);
|
}
|
|
return sb.toString();
|
}
|
|
|
public static Integer decode(String str){
|
|
char[] b=str.toCharArray();
|
StringBuilder sb=new StringBuilder();
|
for (int i = 0; i < b.length; i++) {
|
for(int j=0; j< codes.length;j++ ){
|
if(b[i]==codes[j]){
|
sb.append(j);
|
}
|
}
|
|
}
|
|
return Integer.valueOf(sb.toString());
|
}
|
|
}
|