Java Code Examples for org.apache.commons.codec.digest.DigestUtils#md5Hex()
The following examples show how to use
org.apache.commons.codec.digest.DigestUtils#md5Hex() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultScriptExecutorService.java From hsweb-framework with Apache License 2.0 | 6 votes |
@Override @Transactional(rollbackFor = Throwable.class) public Object execute(String id, Map<String, Object> parameters) throws Exception { ScriptEntity scriptEntity = scriptService.selectByPk(id); if (scriptEntity==null){ return null; } DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(scriptEntity.getLanguage()); String scriptId = "dynamicScript-" + id; String scriptMd5 = DigestUtils.md5Hex(scriptEntity.getScript()); ScriptContext context = engine.getContext(scriptId); if (context == null || !context.getMd5().equals(scriptMd5)) { engine.compile(scriptId, scriptEntity.getScript()); } return engine.execute(scriptId, parameters).getIfSuccess(); }
Example 2
Source File: NECaptchaVerifier.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * 生成签名信息 * * @param secretKey 验证码私钥 * @param params 接口请求参数名和参数值map,不包括signature参数名 * @return */ public static String sign(String secretKey, Map<String, String> params) { String[] keys = params.keySet().toArray(new String[0]); Arrays.sort(keys); StringBuffer sb = new StringBuffer(); for (String key : keys) { sb.append(key).append(params.get(key)); } sb.append(secretKey); try { return DigestUtils.md5Hex(sb.toString().getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace();// 一般编码都支持的。。 } return null; }
Example 3
Source File: TeacherAction.java From SmartEducation with Apache License 2.0 | 6 votes |
/** 添加 */ public String add() throws Exception { /** 保存用户相应信息 */ // 封装到对象中(当model是实体类型时,也可以使用model,但要设置未封装的属性) // >> 设置所属部门和角色 model.setDepartment(departmentService.findById(departmentId)); List<Role> roleList=roleService.findByIds(roleIds); model.setRoles(new HashSet<Role>(roleList)); // 保存数据库 teacherService.save(model); // ** 保存用户登陆信息 */ // >> 设置默认密码为账号(要使用MD5摘要) User userModel = new User(); String md5Digest = DigestUtils.md5Hex(model.getTeaNum()); userModel.setPassword(md5Digest); userModel.setTeacher(model); userModel.setUserNum(model.getTeaNum()); userModel.setUserType("老师"); // 保存到数据库 userService.save(userModel); return "toList"; }
Example 4
Source File: MD5SignatureParseFilter.java From storm-crawler with Apache License 2.0 | 6 votes |
@Override public void filter(String URL, byte[] content, DocumentFragment doc, ParseResult parse) { ParseData parseData = parse.get(URL); Metadata metadata = parseData.getMetadata(); if (copyKeyName != null) { String signature = metadata.getFirstValue(key_name); if (signature != null) { metadata.setValue(copyKeyName, signature); } } byte[] data = null; if (useText) { String text = parseData.getText(); if (StringUtils.isNotBlank(text)) { data = text.getBytes(StandardCharsets.UTF_8); } } else { data = content; } if (data == null) { data = URL.getBytes(StandardCharsets.UTF_8); } String hex = DigestUtils.md5Hex(data); metadata.setValue(key_name, hex); }
Example 5
Source File: JSONPlugin.java From TrackRay with GNU General Public License v3.0 | 6 votes |
private boolean matchMd5(HttpResponse req, String match) { if (req.getStatusCode() != 200) return false; String uuid = UUID.randomUUID().toString(); String body = req.body(); File file = new File(temp.concat(uuid)); try { FileUtils.writeStringToFile(file,body); String md5 = DigestUtils.md5Hex(new FileInputStream(file)); return md5.equals(match); } catch (IOException e) { return false; }finally { if (file.exists()) file.delete(); } }
Example 6
Source File: OAuth2Util.java From carbon-identity with Apache License 2.0 | 5 votes |
public static String hashScopes(String scope) { if (scope != null) { //first converted to an array to sort the scopes return DigestUtils.md5Hex(OAuth2Util.buildScopeString(buildScopeArray(scope))); } else { return null; } }
Example 7
Source File: UserAction.java From SmartEducation with Apache License 2.0 | 5 votes |
/** 跳转修改密码界面 */ public String modifyPassword() throws Exception { if ((DigestUtils.md5Hex(oldPassword.trim())).equals(getCurrentUser() .getPassword())) { String newPass = DigestUtils.md5Hex(newPassword); getCurrentUser().setPassword(newPass); userService.update(getCurrentUser()); addFieldError("information", "密码修改成功"); } else addFieldError("information", "旧密码错误"); return "modifyPasswordUI"; }
Example 8
Source File: GitLabSCMWebHookListener.java From gitlab-branch-source-plugin with GNU General Public License v2.0 | 5 votes |
private String generateId() { try { StringBuilder idBuilder = new StringBuilder(DigestUtils.md5Hex(gitLabConnection(connectionName).getUrl())); if (projectId > 0) { idBuilder.append(HOOK_PATH_SEP).append(projectId); } return idBuilder.toString(); } catch (NoSuchElementException ignore) { // silently ignore and re-generate id later return null; } }
Example 9
Source File: MD5.java From gpmall with Apache License 2.0 | 5 votes |
/** * 签名字符串 * * @param text 需要签名的字符串 * @param sign 签名结果 * @param key 密钥 * @param input_charset 编码格式 * @return 签名结果 */ public static boolean verify(String text, String sign, String key, String input_charset) { text = text + key; String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset)); if (mysign.equals(sign)) { return true; } else { return false; } }
Example 10
Source File: AccessTokenGenerator.java From carbon-apimgt with Apache License 2.0 | 4 votes |
private String getScopeHash(String[] scopes){ Arrays.sort(scopes); return DigestUtils.md5Hex(String.join(" ", scopes)); }
Example 11
Source File: AESUtils.java From rhizobia_J with BSD 3-Clause "New" or "Revised" License | 4 votes |
private AESUtils(String aesKey, String secretKey, String aesMode) { this.secretKey = secretKey; this.aesKey = DigestUtils.md5Hex(DigestUtils.sha256Hex(aesKey + "|" + secretKey) + "|" + secretKey); this.iVector = this.aesKey.substring(8, 24); this.aesMode = aesMode == null ? "AES/CBC/PKCS5Padding" : aesMode; }
Example 12
Source File: RedisCacheWrapper.java From ymate-platform-v2 with Apache License 2.0 | 4 votes |
private String __doSerializeKey(Object key) { if (key instanceof String || key instanceof StringBuilder || key instanceof StringBuffer || key instanceof Number) { return key.toString(); } return DigestUtils.md5Hex(("" + key).getBytes()); }
Example 13
Source File: LocalFilesystemConnector.java From cloudsync with GNU General Public License v2.0 | 4 votes |
private static String createChecksum(final InputStream data) throws IOException { return DigestUtils.md5Hex(data); }
Example 14
Source File: TmpDirCreator.java From Getaviz with Apache License 2.0 | 4 votes |
public File getLocalTempDir() { File returnable = new File(TEMP_DIR.getAbsolutePath() + "/" + DigestUtils.md5Hex(dirPath)); return returnable; }
Example 15
Source File: ResourcePackManager.java From AdditionsAPI with MIT License | 4 votes |
public static void buildResourcePack() throws IOException { // initialize work space File work = new File(AdditionsAPI.getInstance().getDataFolder() + "/resource-pack/work/"); FileUtils.deleteFolder(work); // a temporary file used for downloading resource pack files. File temp = new File(AdditionsAPI.getInstance().getDataFolder() + "/resource-pack/download/temp.zip"); FileUtils.createFileAndPath(temp); // check and download server's original resource pack. downloadResourcePack(work, temp); // process plugin resource packs. processPluginResource(work, temp); // inject custom item model into work space injectCustomItemModels(work); // copy resource pack.meta and logo.png FileUtils.copyResource(AdditionsAPI.getInstance(), "resource/pack.mcmeta", new File(work, "pack.mcmeta")); FileUtils.copyResource(AdditionsAPI.getInstance(), "resource/pack.png", new File(work, "pack.png")); // pack up result resource pack. Debug.sayTrue("Packing complete resource pack."); FileUtils.zip(work, resourceFile); Debug.sayTrue("Resource pack has been constructed."); // remove temporary folder. FileUtils.deleteFolder(work); FileUtils.deleteFolder(temp.getParentFile()); // change last modified date to avoid different md5 for the same contents resourceFile.setLastModified(1500135786000L); FileInputStream fisRP = new FileInputStream(resourceFile); // md5Hex converts an array of bytes into an array of characters representing // the hexadecimal values of each byte in order. // The returned array will be double the length of the passed array, as it takes // two characters to represent any given byte. byte[] isByte = IOUtils.toByteArray(fisRP); resourcePackMd5 = DigestUtils.md5Hex(isByte); resourcePackSha1 = DigestUtils.sha1Hex(isByte); resourcePackSha1Byte = DatatypeConverter.parseHexBinary(resourcePackSha1); fisRP.close(); String currentMd5 = AdditionsAPI.getInstance().getConfig().getString("resource-pack.md5"); if (currentMd5 == null || !currentMd5.equals(resourcePackMd5)) { neededRebuild = true; Debug.say("Changes were detected in the Resource Pack, so it has been rebuilt."); int build = AdditionsAPI.getInstance().getConfig().getInt("resource-pack.build", 0); build++; AdditionsAPI.getInstance().getConfig().set("resource-pack.build", build); AdditionsAPI.getInstance().getConfig().set("resource-pack.md5", resourcePackMd5); } else { Debug.sayTrue("No resource pack change, using cached resource pack."); } // close all stream for (InputStream in : resources) if (in != null) in.close(); resources.clear(); }
Example 16
Source File: CodecUtil.java From wenku with MIT License | 4 votes |
/** * 将字符串 MD5 加密 */ public static String encryptMD5(String str) { return DigestUtils.md5Hex(str); }
Example 17
Source File: MD5.java From shopping with Apache License 2.0 | 2 votes |
/** * 签名字符串 * @param text 需要签名的字符串 * @param key 密钥 * @param input_charset 编码格式 * @return 签名结果 */ public static String sign(String text, String key, String input_charset) { text = text + key; return DigestUtils.md5Hex(getContentBytes(text, input_charset)); }
Example 18
Source File: MD5Util.java From payment with Apache License 2.0 | 2 votes |
/** * 签名字符串 * @param text 需要签名的字符串 * @param sign 签名结果 * @param key 密钥 * @param input_charset 编码格式 * @return 签名结果 */ public static boolean verify(String text, String sign, String key, String input_charset) { text = text + key; String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset)); return mysign.equals(sign); }
Example 19
Source File: MD5.java From roncoo-pay with Apache License 2.0 | 2 votes |
/** * 签名字符串 * @param text 需要签名的字符串 * @param key 密钥 * @param input_charset 编码格式 * @return 签名结果 */ public static String sign(String text, String key, String input_charset) { text = text + key; return DigestUtils.md5Hex(getContentBytes(text, input_charset)); }
Example 20
Source File: MD5Helper.java From dk-foundation with GNU Lesser General Public License v2.1 | 2 votes |
/** * md5加密 * * @param message * @return */ public static String encrypt(String message) { return DigestUtils.md5Hex(message); }