Download

- Stars (0)

0 Downloads

Version: 1.0

Last Updated: 04-10-2019 0:25

Share
DescriptionVersions
co.com.dendritas.KleyberTool.aix

Thread Link

https://community.appybuilder.com/t/md5-encryption-extension/5256/15

public class KleyberTool extends AndroidNonvisibleComponent implements Component { public static final int VERSION = 1; private ComponentContainer container; private Context context; private static final String LOG_TAG = ””; public KleyberTool(ComponentContainer container) { super(container.$form()); this.container = container; context = (Context) container.$context(); Log.d(LOG_TAG, ”KleyberTool” ); } @SimpleFunction(description = ””) public String EncodeMD5(String text){ return MD5.encrypt(text); } public static final class MD5 { /** * Encrypt a text into MD5 * @param text * @return MD5 encrypted text */ public final static String encrypt(final String text) { try { // Create MD5 Hash MessageDigest digest = MessageDigest .getInstance(”MD5”); digest.update(text.getBytes()); byte messageDigest[] = digest.digest(); // Create Hex String StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { String h = Integer.toHexString(0xFF & messageDigest[i]); while (h.length() < 2) h = ”0” + h; hexString.append(h); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return ””; } } }