Java Code Examples for org.apache.commons.codec.digest.DigestUtils#sha1Hex()
The following examples show how to use
org.apache.commons.codec.digest.DigestUtils#sha1Hex() .
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: PrepMetadataExecutionIdGenerator.java From data-prep with Apache License 2.0 | 5 votes |
@Override public String getExecutionId(ProceedingJoinPoint pjp) { // look for AsyncParameter param Object[] args = AnnotationUtils.extractAsyncParameter(pjp); // check pre-condition Validate.notNull(args); Validate.isTrue(args.length == 2); Validate.isInstanceOf(String.class, args[0]); Validate.isInstanceOf(String.class, args[1]); return DigestUtils.sha1Hex(args[0] + "_" + args[1]); }
Example 2
Source File: ActionListWithFilter.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private String getStringListHeyx( List<String> list ) { StringBuffer content = new StringBuffer(); if( ListTools.isNotEmpty( list )) { SortTools.asc( list ); for( String str : list ) { content.append( str ); } return DigestUtils.sha1Hex(content.toString() ); } return "null"; }
Example 3
Source File: SHA1.java From weixin-java-tools with Apache License 2.0 | 5 votes |
/** * 串接arr参数,生成sha1 digest * * @param arr * @return */ public static String gen(String... arr) throws NoSuchAlgorithmException { Arrays.sort(arr); StringBuilder sb = new StringBuilder(); for (String a : arr) { sb.append(a); } return DigestUtils.sha1Hex(sb.toString()); }
Example 4
Source File: GenerateDependencyListMojo.java From camel-k-runtime with Apache License 2.0 | 5 votes |
private Map<String, String> artifactToMap(Artifact artifact) { Map<String, String> dep = new LinkedHashMap<>(); dep.put("id", artifact.getId()); if (artifact.getFile() == null) { return dep; } if (includeLocation) { dep.put("location", artifact.getFile().getAbsolutePath()); } try { String location = artifact.getFile().getAbsolutePath(); String checksum = null; for (String checksumType : CHECKSUM_TYPES) { Path checksumFile = Paths.get(location + "." + checksumType); if (Files.exists(checksumFile)) { checksum = checksumType + ":" + Files.readString(checksumFile, StandardCharsets.UTF_8); break; } } if (checksum == null) { try (InputStream is = Files.newInputStream(artifact.getFile().toPath())) { checksum = "sha1:" + DigestUtils.sha1Hex(is); } } dep.put("checksum", checksum); } catch (IOException e) { throw new RuntimeException(e); } return dep; }
Example 5
Source File: MergeCdrFiles.java From ache with Apache License 2.0 | 5 votes |
private String hashDocument(CDR2Document doc) { String url = doc.getUrl(); url = url.replaceFirst("https?://", ""); if (url.endsWith("/")) { url = url.substring(0, url.length() - 1); } String contentHash = DigestUtils.sha1Hex(doc.getRawContent()); String urlHash= DigestUtils.sha1Hex(doc.getUrl()); return DigestUtils.md5Hex(urlHash+contentHash); }
Example 6
Source File: HtmlBuilderVisitor.java From bonita-ui-designer with GNU General Public License v2.0 | 5 votes |
private String getHash(Asset asset, AssetRepository<?> assetRepository, String previewableId) { try { byte[] content = asset.getComponentId() == null ? assetRepository.readAllBytes(previewableId, asset) : assetRepository.readAllBytes(asset); return DigestUtils.sha1Hex(content); } catch (Exception e) { logger.warn("Failure to generate hash for asset " + asset.getName(), e); return UUID.randomUUID().toString(); } }
Example 7
Source File: QueryFilter.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
/** * 将查询的所有内容组织成String,然后计算一个SHA1 DigestUtils.sha1Hex(content) * * @return */ public String getContentSHA1() { String content = getQueryContent(); if (StringUtils.isEmpty(content)) { return DigestUtils.sha1Hex("null"); } else { return DigestUtils.sha1Hex(content); } }
Example 8
Source File: SHA1.java From weixin-java-tools with Apache License 2.0 | 5 votes |
/** * 用&串接arr参数,生成sha1 digest * * @param arr * @return */ public static String genWithAmple(String... arr) throws NoSuchAlgorithmException { Arrays.sort(arr); StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.length; i++) { String a = arr[i]; sb.append(a); if (i != arr.length - 1) { sb.append('&'); } } return DigestUtils.sha1Hex(sb.toString()); }
Example 9
Source File: ActionListWithFilter.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private String getStringListHeyx( List<String> list ) { StringBuffer content = new StringBuffer(); if( ListTools.isNotEmpty( list )) { SortTools.asc( list ); for( String str : list ) { content.append( str ); } return DigestUtils.sha1Hex(content.toString() ); } return "null"; }
Example 10
Source File: Assertions.java From mattermost4j with Apache License 2.0 | 4 votes |
public static void assertSameFile(Path expected, Path actual) throws IOException { String expectedHash = DigestUtils.sha1Hex(Files.readAllBytes(expected)); String actualHash = DigestUtils.sha1Hex(Files.readAllBytes(actual)); assertEquals(expectedHash, actualHash); }
Example 11
Source File: TargetModelCbor.java From ache with Apache License 2.0 | 4 votes |
public String computeReverseKey(URL url) { String urlSha1Hash = DigestUtils.sha1Hex(url.toString()); String reverseDomain = reverseDomain(url.getHost()); return reverseDomain + "_" + urlSha1Hash + "_" + timestamp; }
Example 12
Source File: AnonymizeProcessor.java From sawmill with Apache License 2.0 | 4 votes |
@Override public String anonimize(String value) { return DigestUtils.sha1Hex(value); }
Example 13
Source File: WxMaUserServiceImpl.java From weixin-java-tools with Apache License 2.0 | 4 votes |
@Override public boolean checkUserInfo(String sessionKey, String rawData, String signature) { final String generatedSignature = DigestUtils.sha1Hex(rawData + sessionKey); return generatedSignature.equals(signature); }
Example 14
Source File: SqlFunctions.java From calcite with Apache License 2.0 | 4 votes |
/** SQL SHA1(string) function for binary string. */ public static @Nonnull String sha1(@Nonnull ByteString string) { return DigestUtils.sha1Hex(string.getBytes()); }
Example 15
Source File: SqlFunctions.java From Quicksql with MIT License | 4 votes |
/** SQL SHA1(string) function. */ public static @Nonnull String sha1(@Nonnull String string) { return DigestUtils.sha1Hex(string.getBytes(UTF_8)); }
Example 16
Source File: FeedFetcher.java From commafeed with Apache License 2.0 | 4 votes |
public FetchedFeed fetch(String feedUrl, boolean extractFeedUrlFromHtml, String lastModified, String eTag, Date lastPublishedDate, String lastContentHash) throws FeedException, IOException, NotModifiedException { log.debug("Fetching feed {}", feedUrl); FetchedFeed fetchedFeed = null; int timeout = 20000; HttpResult result = getter.getBinary(feedUrl, lastModified, eTag, timeout); byte[] content = result.getContent(); try { fetchedFeed = parser.parse(result.getUrlAfterRedirect(), content); } catch (FeedException e) { if (extractFeedUrlFromHtml) { String extractedUrl = extractFeedUrl(urlProviders, feedUrl, StringUtils.newStringUtf8(result.getContent())); if (org.apache.commons.lang3.StringUtils.isNotBlank(extractedUrl)) { feedUrl = extractedUrl; result = getter.getBinary(extractedUrl, lastModified, eTag, timeout); content = result.getContent(); fetchedFeed = parser.parse(result.getUrlAfterRedirect(), content); } else { throw e; } } else { throw e; } } if (content == null) { throw new IOException("Feed content is empty."); } String hash = DigestUtils.sha1Hex(content); if (lastContentHash != null && hash != null && lastContentHash.equals(hash)) { log.debug("content hash not modified: {}", feedUrl); throw new NotModifiedException("content hash not modified"); } if (lastPublishedDate != null && fetchedFeed.getFeed().getLastPublishedDate() != null && lastPublishedDate.getTime() == fetchedFeed.getFeed().getLastPublishedDate().getTime()) { log.debug("publishedDate not modified: {}", feedUrl); throw new NotModifiedException("publishedDate not modified"); } Feed feed = fetchedFeed.getFeed(); feed.setLastModifiedHeader(result.getLastModifiedSince()); feed.setEtagHeader(FeedUtils.truncate(result.getETag(), 255)); feed.setLastContentHash(hash); fetchedFeed.setFetchDuration(result.getDuration()); fetchedFeed.setUrlAfterRedirect(result.getUrlAfterRedirect()); return fetchedFeed; }
Example 17
Source File: ClassCodeCacheKey.java From nuls with MIT License | 4 votes |
public ClassCodeCacheKey(byte[] bytes) { this.bytes = bytes; this.key = DigestUtils.sha1Hex(bytes); }
Example 18
Source File: Si.java From sissi with Apache License 2.0 | 4 votes |
public String host(String from, String to) { return DigestUtils.sha1Hex(this.getId() + from + to); }
Example 19
Source File: QQHelper.java From seed with Apache License 2.0 | 3 votes |
/** * JS-SDK权限验证的签名 * @see 注意这里使用的是noncestr,不是nonceStr * @param noncestr 随机字符串 * @param timestamp 时间戳 * @param url 当前网页的URL,不包含#及其后面部分 * @create Nov 28, 2015 8:48:52 PM * @author 玄玉<https://jadyer.cn/> */ public static String signQQJSSDK(String appid, String noncestr, String timestamp, String url){ StringBuilder sb = new StringBuilder(); sb.append("jsapi_ticket=").append(QQTokenHolder.getQQJSApiTicket(appid)).append("&") .append("noncestr=").append(noncestr).append("&") .append("timestamp=").append(timestamp).append("&") .append("url=").append(url); return DigestUtils.sha1Hex(sb.toString()); }
Example 20
Source File: ApplicationUtils.java From mySpringBoot with Apache License 2.0 | 2 votes |
/** * sha1加密 * * @param value 要加密的值 * @return sha1加密后的值 */ public static String sha1Hex(String value) { return DigestUtils.sha1Hex(value); }