Java String Encrypt Encrypt(String str, String salt)

Here you can find the source of Encrypt(String str, String salt)

Description

Encrypt

License

Apache License

Declaration

public static String Encrypt(String str, String salt) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String Encrypt(String str, String salt) {
        String encoderText = "lsedfoglkwjemc-091324jlkmsda-0sd=1234;l;lsdkOPIER203-4LKJSLDJAS0D925JKNNC,MANSLDJQ32ELK1N4SAIp089er0234lkjo9df82l3kjlknf,nzxc,mn;lasdj9wquelq;d]qowe[;wq;qkwellsdkfj0-0POPOAR0W8RPOp-02@#$sdklj$#)0asdlksadLKJFA9820934)(&$3ij09sdj34-sdfj2po345-09dlkfjlkv,mxncv;laskdkl/a;au093hakjh2389~!@%&*%#&^539478(*&)^(&^_*8-*_+++|78w3ihsdnmnclksdj)(*#%*_@$(+#@$)&@#^*&^#@$()(*#@$HDFIkdhfgkjh098k;ldsk.sdv.c,msd;flkp0w34;2lk-=sd0p121o39-werl2k3;4lj09sdflskjlekfj,mv,mcxvjlksjdflksjdl*(#@!&akhduyqweperilmmdxcasnd*(#@9879327kjhasudfewr kwehriwueyrhc ausdgiq7w8e71 cdsh93ol2q32879y8932qwhdkjanhdskjaoe*&w#jh$)(*dsFshc na89wue32e981yewher12(*&#quds)(*i3o1928osaihdaklsdkalkduqowe3290874kljhklasdhlijhqweio4hwe89(*$#$eriho349oij(#*q$OIJHO)(&*#$_)(IUDSOIUoiOIUSAODFU034liusdrogiuet0lsdmc,.mg;lq-091lk3l;kjsdf--123098fe*(JOKJSFD983345oihjdp0(#*$&#@!HKJH!(@#*&ioysdk@#)uhOA7E98R7239845K(*&(#@*$&HKFDJHWERYIWoi)(*&#@&^%@!dsfoi;.;,p[osklejr230897*(&we2&^%@78*(&#@!(7~&*~^@*&^#(*&auroiqkjwrhoasdf89qlrlkjpour09werk23jh";
        encoderText += salt;//from ww w  .  j  a v  a  2  s.c om
        int seed = (int) Random(255);
        int pre = seed & 3;
        int len = str.length();
        int elen = encoderText.length();
        int i, j;

        String ret = "";
        ret += EncodeChar(seed);
        ret += EncodeChar((((int) Random(255)) & 0xfc) + pre);
        for (i = 0; i < pre; i++)
            ret += EncodeChar((int) Random(255));

        for (i = 0, j = seed; i < len; i++) {
            ret += EncodeChar((str.charAt(i)) ^ (encoderText.charAt(j)));
            if (++j >= elen)
                j = 0;
        }

        //System.out.println("enc: "+ret);
        return ret;
    }

    public static double Random(int x) {
        return (Math.floor(Math.random() * 1000000)) % x;
    }

    public static String EncodeChar(int c) {
        String s = "";
        double x = Math.floor(c / 16);
        if (x > 9) {
            s += (char) (((int) x) - 10 + 0x61);
        } else {
            s += (int) x;
        }
        x = c % 16;
        if (x > 9) {
            s += (char) (((int) x) - 10 + 0x61);
        } else {
            s += (int) x;
        }
        return s;
    }
}

Related

  1. encrypt(String inStr)
  2. encrypt(String s)
  3. encrypt(String s)
  4. encrypt(String str)
  5. Encrypt(String str)
  6. encrypt(String string)
  7. encrypt(String string)
  8. encrypt0(final byte[] result)
  9. encryptBankCardNo(String cardNo)