Red de conocimiento informático - Conocimiento sistemático - ¡Por favor! ! ! ¡El código fuente de cifrado transparente para el usuario escrito en Java es urgente! ! ! ¡Los expertos ayudan! ! !

¡Por favor! ! ! ¡El código fuente de cifrado transparente para el usuario escrito en Java es urgente! ! ! ¡Los expertos ayudan! ! !

Encontré uno en línea hace mucho tiempo. No sé si ayudará a LZ.

Paquete TestNativeOutOfMemoryError

Importar Java.security.key;

Importar Java.security.securerandom;

Importar javax.crypto.cipher ;

Importar generador de claves javax .crypto;

Descifrado de clase pública {

Clave clave;

/**

*Generar una clave con parámetros

*

* @param strKey

*/

public void getKey( String strKey){

Prueba{

generador de claves _ generador = generador de claves . getinstance(" DES "); init(new SecureRandom( strkey . . getbytes()));

esta clave = _ generador . generar clave();

_ generador = nulo

} captura (Excepción e) {

e . printstacktrace();

}

}

/**

*Cifrado

*

* @param cadena a cifrar

* @return

*/

Cadena de caracteres públicos getEncString(String strMing) {

byte[]byte mi = nulo

byte[]byte Ming = nulo

String strMi =

p>

Intente {

Devolver byte 2 hex(getEncCode(strming . getbytes()));

//byte Ming = strming(" UTF8. ");

//byte mi = this . getenccode(byte Ming);

// strMi = new String(byteMi, " UTF8 ");

} catch (Excepción e) {

e . printstacktrace();

}Finalmente {

byteMing = null

byteMi = nulo

p>

}

Devolver strMi

}

/**

*Descifrar

*

* @param strMi

* @return

*/

Cadena pública getDesString(String strMi) {

byte[]byte Ming = nulo;

byte[]byte mi = nulo;

Cadena strMing =

Pruebe {

Devuelve nueva cadena (get descode(hex 2 byte(strmi . getbytes())));

//byte Ming = this . >

// strMing = new String(byteMing, " UTF8 ");

} catch (Excepción e)

{

e . printstacktrace();

}Finalmente {

byteMing = null

byteMi = null

}

Cadena de retorno;

}

Byte privado[] getEncCode(byte[]byte){

byte[]byte fina = null;

Contraseña contraseña;

Pruebe {

cipher = cipher . getinstance(" DES ");

cipher. init(contraseña.ENCRYPT_MODE,clave);

byteFina = cipher.doFinal(byte);

} catch(Exception e) {

e. );

}Finalmente {

cipher = null

}

Devuelve byteFina

}

Byte privado[] Obtener código de descripción (byte[]byte){

Contraseña contraseña;

byte[]byte fina = null ;

Pruebe {

cipher = cipher . getinstance(" DES ");

cipher.init(contraseña.

DECRYPT_MODE, clave);

byte fina = cifrado. hacer final(byteD);

} catch (Excepción e) {

e .

}Finalmente {

cipher = null

}

Devuelve byteFina

}

Cadena estática pública byte2hex(byte[] b) {

String hs =

String stmp =

for(int n = 0; n & ltb longitud; n++) {

stmp =(Java . lang . entero . tohexstring(b[n]& amp; 0x ff)); == 1)

hs = hs+" 0 "+stmp;

Otro

hs = hs+stmp;

}

Devuelve hs .toupper case();

}

Byte estático público[]hexbyte(byte[]b ) {

if ((b.length % 2)!= 0)

Lanza una nueva IllegalArgumentException(" datos no legales ");

byte [] b2 = nuevo byte [b . ];

for(int n = 0; n & ltb . length; n += 2) {

Elemento de cadena = new String(b, n, 2);

B2[n/2]=(byte)entero. analizar int(elemento, 16);

}

Devuelve B2;

}

Public static void main(String[] args) {

DesEncrypt des = new DesEncrypt();

des .

string strEnc = DES . getencstring("prueba de cifrado DES");

system out . (strEnc);

sistema . println(strDes);

nuevo DesEncrypt(); p>