No wordy, look at the code, very simple
Import Psdi.mbo.MboRemote;
Import Psdi.mbo.MboSetRemote;
Import Psdi.util.MXCipher;
Import Psdi.util.MXCipherX;
Import psdi.util.MXSession;
public class Test {private static final String SERVER = "Localhost:1099/mxserver";
private static final String super_username = "admin";
private static final String Super_password = "admin";
public static void Main (string[] args) throws Exception {test test = new test ();
String Password = "admin";
String Encryptedpassword = test.encrypt (password);
String Decryptedpassword = Test.decrypt (Encryptedpassword);
System.out.println ("Password:" + password);
System.out.println ("Encryptedpassword:" + Encryptedpassword);
System.out.println ("Decryptedpassword:" + Decryptedpassword);
private string Encrypt (string password) throws Exception {string encryptedpassword = "0x";
byte[] bytes = Getmxcipherx (). Encdata (password);
for (int i = 0; i < bytes.length i++) {int b = bytes[i]; String hex = integer.tohexstring (b). toUpperCase ();
Hex = Hex.replaceall ("FFFFFF", ""); Hex = (hex.length () < 2)?
"0" + Hex:hex;
Encryptedpassword + = hex;
return Encryptedpassword; private string Decrypt (string Encryptedpassword) throws Exception {Encryptedpassword = encryptedpassword.substring
(2, Encryptedpassword.length ());
int length = Encryptedpassword.getbytes (). Length/2;
byte[] bytes = new Byte[length]; for (int i = 0; i < length; i++) {Bytes[i] = (byte) integer.decode ("0x" + encryptedpassword.substring (i * 2, I * 2 +
2)). Intvalue ();
String password = getmxcipher (). Decdata (bytes);
return password;
Private Mxcipherx Getmxcipherx () throws Exception {mxsession mxsession = mxsession.getsession ();
Mxsession.sethost (SERVER);
Mxsession.setusername (Super_username);
Mxsession.setpassword (Super_password);
Mxsession.connect ();
Mxcipherx Mxcipherx = new Mxcipherx (Mxsession.getmxserverremote ());
Mxsession.disconnect ();
return Mxcipherx; Private MXCIPher Getmxcipher () throws Exception {mxsession mxsession = mxsession.getsession ();
Mxsession.sethost (SERVER);
Mxsession.setusername (Super_username);
Mxsession.setpassword (Super_password);
Mxsession.connect ();
Mxcipher mxcipher = new Mxcipher (Mxsession.getmxserverremote ());
Mxsession.disconnect ();
return mxcipher;
}
}