List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex
public static String md5Hex(String data)
From source file:de.appsolve.padelcampus.controller.CacheManifestController.java
@RequestMapping(value = "/cache.manifest", produces = "text/cache-manifest") @ResponseBody// ww w. j a v a 2s . com public String generateManifest() throws IOException { StringBuilder hash = new StringBuilder(); StringBuilder sb = new StringBuilder(); sb.append("CACHE MANIFEST\n"); sb.append("CACHE:\n"); appendFolder(sb, hash, "css"); appendFolder(sb, hash, "js"); appendFolder(sb, hash, "images"); appendFolder(sb, hash, "fonts"); sb.append("\nNETWORK:\n"); sb.append("cache.manifest"); sb.append("\nFALLBACK:\n"); appendFolder(sb, hash, "jsp/offline", "/ /offline"); sb.append("# MD5: ").append(DigestUtils.md5Hex(hash.toString())); return sb.toString(); }
From source file:net.shopxx.service.impl.CouponCodeServiceImpl.java
public CouponCode generate(Coupon coupon, Member member) { Assert.notNull(coupon);//from w w w . j a va 2s .c om CouponCode couponCode = new CouponCode(); couponCode.setCode(coupon.getPrefix() + DigestUtils.md5Hex(UUID.randomUUID() + RandomStringUtils.randomAlphabetic(30)).toUpperCase()); couponCode.setIsUsed(false); couponCode.setCoupon(coupon); couponCode.setMember(member); return super.save(couponCode); }
From source file:dk.deck.resolver.AbstractArtifactResolver.java
protected boolean verifyMd5(String md5, File file) throws IOException { String md5Hex = DigestUtils.md5Hex(new FileInputStream(file)); if (!md5Hex.toLowerCase().equals(md5.toLowerCase())) { return false; } else {/*from w w w.j a va2 s . co m*/ return true; } }
From source file:com.codercowboy.photo.organizer.service.PhotoIndexer.java
public static Photo indexFile(File f) throws Exception { if (!f.exists()) { throw new IOException("Cannot index file, file does not exist: " + f.getAbsolutePath()); }/*from w ww .j a v a 2 s . c om*/ if (!f.canRead()) { throw new IOException( "Cannot index file, file is not readable, permission denied:" + f.getAbsolutePath()); } Photo p = new Photo(); p.setName(f.getName()); //TODO: this should be relative path to parent p.setFileRelativePath(f.getAbsolutePath()); p.setFileSize(f.length()); FileInputStream fis = new FileInputStream(f); try { p.setMd5Checksum(DigestUtils.md5Hex(fis)); } finally { fis.close(); } return p; }
From source file:fi.ilmoeuro.membertrack.person.Person.java
public String getGravatarUrl() { return String.format("//gravatar.com/avatar/%s?d=mm", DigestUtils.md5Hex(getEmail().toLowerCase(Locale.ROOT).trim())); }
From source file:edu.psu.citeseerx.utility.FileDigest.java
/** * Calculates a file's MD5 digest and returns it as a 32 character hex string * @param toDigest Data to digest /*w w w . j a va2 s . c o m*/ * @return MD5 digest as a HEX string */ public static String md5Hex(File toDigest) { byte[] fileContent = getFileContent(toDigest); return DigestUtils.md5Hex(fileContent); }
From source file:com.baifendian.swordfish.common.utils.http.HttpUtil.java
/** * md5/*from w ww .j a v a 2 s .c o m*/ */ public static String getMd5(String raw) { if (raw == null) { raw = StringUtils.EMPTY; } return DigestUtils.md5Hex(raw); }
From source file:br.com.jsf.cd.bean.UsuarioCon.java
public String md5Encript() { String encript = DigestUtils.md5Hex(this.obj.getSenhaUsuario()); return encript; }
From source file:com.shenit.commons.utils.AvatarUtils.java
/** * Get Avataer url//w ww . ja va 2 s.c o m * * @param uid * @param width * @param height * @param prefix * @param type * @return */ public static String getAvatarURI(Number uid, Number width, Number height, String prefix, AvatarIdTypeEnum type) { if (ValidationUtils.all(ValidationUtils.NULL, uid, width, height, prefix)) return null; long uidl = uid.longValue(); String hash = null; String path, name; if (type == AvatarIdTypeEnum.YY) { hash = String.valueOf(hashUid(String.valueOf(uidl), false)); path = name = String.valueOf(uid); } else { String hashId = DigestUtils.md5Hex(String.valueOf(uidl)); hash = String.valueOf(hashUid(hashId, true)); path = hashId.substring(0, 2); name = hashId.substring(2); } return String.format(AVATAR_FORMAT, prefix, hash, path, name, width.intValue(), height.intValue()); }
From source file:com.wipro.ats.bdre.filemon.FileScan.java
public static void scanAndAddToQueue() { try {// w w w . j a va 2s.c om String scanDir = FileMonRunnableMain.getMonitoredDirName(); LOGGER.debug("Scanning directory: " + scanDir); File dir = new File(scanDir); if (!dir.exists()) { LOGGER.info("Created monitoring dir " + dir + " success=" + dir.mkdirs()); } File arcDir = new File(scanDir + "/" + FileMonRunnableMain.ARCHIVE); if (!arcDir.exists()) { LOGGER.info("Created monitoring dir " + arcDir + " success=" + arcDir.mkdirs()); } // Getting list of files recursively from directory except '_archive' directory Collection<File> listOfFiles = FileUtils.listFiles(dir, new RegexFileFilter(FileMonRunnableMain.getFilePattern()), new RegexFileFilter("^(?:(?!" + FileMonRunnableMain.ARCHIVE + ").)*$")); String fileName = ""; FileCopyInfo fileCopyInfo = null; for (File file : listOfFiles) { fileName = file.getName(); LOGGER.debug("Matched File Pattern by " + fileName); fileCopyInfo = new FileCopyInfo(); fileCopyInfo.setFileName(fileName); fileCopyInfo.setSubProcessId(FileMonRunnableMain.getSubProcessId()); fileCopyInfo.setServerId(Integer.toString(123461)); fileCopyInfo.setSrcLocation(file.getAbsolutePath()); fileCopyInfo.setDstLocation(file.getParent().replace(FileMonRunnableMain.getMonitoredDirName(), FileMonRunnableMain.getHdfsUploadDir())); fileCopyInfo.setFileHash(DigestUtils.md5Hex(FileUtils.readFileToByteArray(file))); fileCopyInfo.setFileSize(file.length()); fileCopyInfo.setTimeStamp(file.lastModified()); FileMonitor.addToQueue(fileName, fileCopyInfo); } } catch (Exception err) { LOGGER.error("Error in scan directory ", err); throw new BDREException(err); } }