技术挑战——根据编码函数写出解码函数

第一个粘出解码函数的人将得到价值几百美元的混淆工具,据评价也是目前最好的混淆器。当然,前题是你想要:)。

public class Base64Coder
{

    public static void main(String[] args)
    {
     String a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";//这里不技持中文
     String ru;
     char[] ch;
     try{
      byte[] bt= a.getBytes("UTF-8");
      ch = encrypt(bt);
      //ru = new String(decrypt(ch));
      System.out.println(ru);
     }catch(Exception e){}
    }
    public static char[] encrypt(byte abyte0[])
    {
        int i = abyte0.length;
        int j = (i * 4 + 2) / 3;
        int k = ((i + 2) / 3) * 4;
        char ac[] = new char[k];
        int l = 0;
        for(int i1 = 0; l < i; i1++)
        {
            int j1 = abyte0[l++] & 0xff;
            int k1 = l >= i ? 0 : abyte0[l++] & 0xff;
            int l1 = l >= i ? 0 : abyte0[l++] & 0xff;
            int i2 = j1 >>> 2;
            int j2 = (j1 & 3) << 4 | k1 >>> 4;
            int k2 = (k1 & 0xf) << 2 | l1 >>> 6;
            int l2 = l1 & 0x3f;
            ac[i1++] = cChar[i2];
            ac[i1++] = cChar[j2];
            ac[i1] = i1 >= j ? '=' : cChar[k2];
            i1++;
            ac[i1] = i1 >= j ? '=' : cChar[l2];
        }

        return ac;
    }

    private static char cChar[];
    private static byte bByte[];

    static
    {
        cChar = new char[64];
        int i = 0;
        for(char c = 'A'; c <= 'Z'; c++)
            cChar[i++] = c;

        for(char c1 = 'a'; c1 <= 'z'; c1++)
            cChar[i++] = c1;

        for(char c2 = '0'; c2 <= '9'; c2++)
            cChar[i++] = c2;

        cChar[i++] = '+';
        cChar[i++] = '/';
        bByte = new byte[128];
        for(int j = 0; j < bByte.length; j++)
            bByte[j] = -1;

        for(int k = 0; k < 64; k++)
            bByte[cChar[k]] = (byte)k;

    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值