public static Object unserializeFromString(String value, ClassLoader cl) throws IOException, ClassNotFoundException { if (value == null) return null; byte[] bytes = fromBinaryString(value); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); @SuppressWarnings("resource") MObjectInputStream ois = new MObjectInputStream(bais, cl); return ois.readObject(); }
/** * Check if the md5 and the real are the same. The md5 must be created with * md5Salt before. * @param md5 * @param real * @return true if the both values are the same and no exception was thrown */ public static boolean validateMd5WithSalt(String md5, String real) { try { MessageDigest md = MessageDigest.getInstance("MD5"); // take salt from md5 byte[] salt = MCast.fromBinaryString(md5.substring(0,4)); // calculate md5 md.update(salt); md.update(real.getBytes()); String realMd5 = MCast.toBinaryString(md.digest()); // compare return realMd5.equals(md5.substring(4)); } catch (Throwable e) { log.t(e); } return false; }
String data = cdata.getData(); try { Object obj = MCast.fromBinary( MCast.fromBinaryString(data) ); attr.set(to, obj); } catch (ClassNotFoundException e1) {