当前位置: 首页>>代码示例>>Java>>正文


Java DigestUtils.sha1Hex方法代码示例

本文整理汇总了Java中org.apache.commons.codec.digest.DigestUtils.sha1Hex方法的典型用法代码示例。如果您正苦于以下问题:Java DigestUtils.sha1Hex方法的具体用法?Java DigestUtils.sha1Hex怎么用?Java DigestUtils.sha1Hex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.codec.digest.DigestUtils的用法示例。


在下文中一共展示了DigestUtils.sha1Hex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: blur

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/blur", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<InputStreamResource> blur(@RequestParam("source") String sourceUrl, HttpServletResponse response) {
    if (!StringUtils.startsWithAny(sourceUrl, ALLOWED_PREFIX)) {
        return ResponseEntity.badRequest().build();
    }

    String hash = DigestUtils.sha1Hex(sourceUrl);

    try {
        ImageInfo info = readCached(hash);
        if (info == null) {
            info = renderImage(sourceUrl);
            if (info != null) {
                saveCached(hash, info);
            }
        }
        if (info != null) {
            return ResponseEntity.ok()
                    .contentLength(info.contentLength)
                    .contentType(MediaType.IMAGE_JPEG)
                    .body(new InputStreamResource(info.inputStream));
        }
    } catch (IOException e) {
        // fall down
    }
    return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:29,代码来源:BlurImageController.java

示例2: sendMessage

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
public void sendMessage (final String data) {
	FirebaseMessaging fm = FirebaseMessaging.getInstance();

	String token = FirebaseInstanceId.getInstance().getToken();
	String msgID = DigestUtils.sha1Hex(token + System.currentTimeMillis());
	String SENDER_ID = "someID";

	RemoteMessage.Builder RMBuilder =
	new RemoteMessage.Builder(SENDER_ID + "@gcm.googleapis.com");
	RMBuilder.setMessageId(msgID);

	Map<String, Object> mapData = Utils.jsonToMap(data);

	for (Map.Entry<String, Object> entry : mapData.entrySet()) {
		RMBuilder.addData(entry.getKey(), entry.getValue().toString());
	}

	fm.send(RMBuilder.build());
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:20,代码来源:Notification.java

示例3: sha

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
 * @param message {@link String}
 * @param type    {@link HashType}
 * @return {@link String}
 */
private static String sha(String message, HashType type) {
    switch (type) {
        case SHA1:
            return DigestUtils.sha1Hex(message);
        case SHA256:
            return DigestUtils.sha256Hex(message);
        case SHA512:
            return DigestUtils.sha512Hex(message);
        default:
            return DigestUtils.sha256Hex(message);
    }
}
 
开发者ID:farchanjo,项目名称:webcron,代码行数:18,代码来源:HashUtils.java

示例4: sha1

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
public static String sha1(String str){
    String s = null;
    try {
        byte[] data = str.getBytes("UTF-8");

        s = DigestUtils.sha1Hex(data);
    }catch (Exception ex){
        ex.printStackTrace();
    }

    return s;
}
 
开发者ID:noear,项目名称:JtSQL,代码行数:13,代码来源:EncryptUtil.java

示例5: ResourceBundle

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
private ResourceBundle(ResourceType resourceType, File virtualFile, String key) {
	this.resourceType= resourceType; 
	this.virtualFile = virtualFile;
	key = key.replaceFirst("(.*?)/_private/(?:flashupdate|mobile)/", "$1/DisplayObjects/mobile/");
	key = DigestUtils.md5Hex(key) + DigestUtils.sha1Hex(key) + "." + resourceType.name();
	cacheFile = new File(minificationCacheDirectory, key);
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:8,代码来源:MinificationManager.java

示例6: checkLogin

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
private UserEntity checkLogin(String email, String password) {
	password = (DigestUtils.sha1Hex(password));
	if (email != null && !email.isEmpty() && !password.isEmpty()) {
		UserEntity userEntity = userDao.findByEmail(email);
		if (userEntity != null) {
			if (password.equals(userEntity.getPassword())) {
				return userEntity;
			}
		}
	}
	return null;
}
 
开发者ID:SoapboxRaceWorld,项目名称:soapbox-race-core,代码行数:13,代码来源:PromoCodeBO.java

示例7: genWithAmple

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
 * 用&串接arr参数,生成sha1 digest
 */
public static String genWithAmple(String... arr) {
  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());
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:16,代码来源:SHA1.java

示例8: __buildJsApiConfigStr

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
private String __buildJsApiConfigStr(String appId, String jsapiTicket, String url, String timestamp, String noncestr, boolean debug) throws Exception {
    String _signature = "jsapi_ticket=" + jsapiTicket + "&" + "noncestr=" + noncestr + "&" + "timeStamp=" + timestamp + "&" + "url=" + url;
    _signature = DigestUtils.sha1Hex(_signature);
    //
    JSONObject _json = new JSONObject();
    _json.put("debug", debug);
    _json.put("appId", appId);
    _json.put("timestamp", timestamp);
    _json.put("nonceStr", noncestr);
    _json.put("signature", _signature);
    _json.put("jsApiList", new String[]{"chooseWXPay"});
    //
    return _json.toJSONString();
}
 
开发者ID:suninformation,项目名称:ymate-payment-v2,代码行数:15,代码来源:WxPayJsApiController.java

示例9: generateUniqueId

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
public static String generateUniqueId(String metrics) {    // 相同的metrics定会产生相同的uniqueID
	String metricsID = DigestUtils.sha1Hex(metrics + atomicInteger.incrementAndGet());    // 40个字符组成
	char[] _chars = metricsID.toCharArray();
	StringBuilder sb = new StringBuilder();
	for(int i = 0; i < _chars.length; i ++ ) {
		if(i % 10 == 0 && i != 0) {	// 10、20和30
			sb.append("-");
		}
		sb.append(String.valueOf(_chars[i]));
	}
	
	return sb.toString();
}
 
开发者ID:dk900912,项目名称:alerts-forwarder,代码行数:14,代码来源:AppUtils.java

示例10: makeSignBySinpleFieldList

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
 * 根据SinpleField列表生成签名
 *
 * 加2个参数   delimiter,caseConvert
 *
 * @param fieldPaireds SinpleField的列表
 * @param salt partnerApiKey
 * @return 生成的签名字符串
 */
private static String makeSignBySinpleFieldList(List<FieldPaired> fieldPaireds, String salt,
    Boolean excludeKeyParameter, SignatureAlgorithmic algorithmic, String saltParameterPrefix,
    String charset, CaseControl caseControl, String delimiter) {
  List<String> list = fieldPaireds.stream()
      .sorted(new AsciiSortedComparator<>(FieldPaired::getProperty)).map(
          FieldPaired::toString).collect(Collectors.toList());

  //在对象上添加特殊属性, 当不排除时添加
  if (!excludeKeyParameter) {
    if (StringUtils.isEmpty(saltParameterPrefix)) {
      throw new RuntimeException("指定了需要添加KEY=到salt前面, 却没有指定前前缀, 请检查官方文档,再做相应调整");
    }
    list.add(saltParameterPrefix + salt);
  }

  // 未加密字符串
  String unencrypted = "";
  try {
    unencrypted = new String(String.join(delimiter, list).getBytes(), charset);
    //将salt添加到最后面
    if (!StringUtils.isEmpty(salt)) {
      if (excludeKeyParameter) {
        unencrypted += salt;
      }
    }
    log.debug("Unencrypted String is: {}", unencrypted);
  } catch (Exception e) {
    e.printStackTrace();
  }

  String result = "";
  switch (algorithmic) {
    case MD2:
      result = DigestUtils.md2Hex(unencrypted);
      break;
    case MD5:
      result = DigestUtils.md5Hex(unencrypted);
      break;
    case SHA1:
      result = DigestUtils.sha1Hex(unencrypted);
      break;
    case SHA256:
      result = DigestUtils.sha256Hex(unencrypted);
      break;
    case SHA384:
      result = DigestUtils.sha384Hex(unencrypted);
      break;
    case SHA512:
      result = DigestUtils.sha512Hex(unencrypted);
      break;
    default:
      throw new RuntimeException("不支持的签名类型");
  }

  if (null != caseControl) {
    switch (caseControl) {
      case TO_LOWER_CASE:
        result = result.toLowerCase();
        break;
      case TO_UPPER_CASE:
        result = result.toUpperCase();
        break;
    }
  }

  log.debug("Encrypted Signature is: {}", result);
  return result;

}
 
开发者ID:minlia-projects,项目名称:minlia-iot,代码行数:79,代码来源:XmlSignatureAnnotationHelper.java

示例11: checkHash

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
private boolean checkHash(String p_190113_1_, File p_190113_2_)
{
    try
    {
        String s = DigestUtils.sha1Hex((InputStream)(new FileInputStream(p_190113_2_)));

        if (p_190113_1_.isEmpty())
        {
            LOGGER.info("Found file {} without verification hash", new Object[] {p_190113_2_});
            return true;
        }

        if (s.toLowerCase(java.util.Locale.ROOT).equals(p_190113_1_.toLowerCase(java.util.Locale.ROOT)))
        {
            LOGGER.info("Found file {} matching requested hash {}", new Object[] {p_190113_2_, p_190113_1_});
            return true;
        }

        LOGGER.warn("File {} had wrong hash (expected {}, found {}).", new Object[] {p_190113_2_, p_190113_1_, s});
    }
    catch (IOException ioexception)
    {
        LOGGER.warn("File {} couldn\'t be hashed.", new Object[] {p_190113_2_, ioexception});
    }

    return false;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:28,代码来源:ResourcePackRepository.java

示例12: checkHash

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
private boolean checkHash(String p_190113_1_, File p_190113_2_)
{
    try
    {
        String s = DigestUtils.sha1Hex((InputStream)(new FileInputStream(p_190113_2_)));

        if (p_190113_1_.isEmpty())
        {
            LOGGER.info("Found file {} without verification hash", new Object[] {p_190113_2_});
            return true;
        }

        if (s.toLowerCase().equals(p_190113_1_.toLowerCase()))
        {
            LOGGER.info("Found file {} matching requested hash {}", new Object[] {p_190113_2_, p_190113_1_});
            return true;
        }

        LOGGER.warn("File {} had wrong hash (expected {}, found {}).", new Object[] {p_190113_2_, p_190113_1_, s});
    }
    catch (IOException ioexception)
    {
        LOGGER.warn("File {} couldn\'t be hashed.", new Object[] {p_190113_2_, ioexception});
    }

    return false;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:28,代码来源:ResourcePackRepository.java

示例13: encryptSHA

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
 * 将字符串 SHA 加密
 */
public static String encryptSHA(String str) {
    return DigestUtils.sha1Hex(str);
}
 
开发者ID:smxc,项目名称:garlicts,代码行数:7,代码来源:CodecUtil.java

示例14: UserVO

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
public UserVO(String email, String password) {
	this.email = email;
	this.password = password;
	this.shaPassword = DigestUtils.sha1Hex(password);
}
 
开发者ID:SoapboxRaceWorld,项目名称:soapbox-race-jlauncher,代码行数:6,代码来源:UserVO.java

示例15: buildAuthorizationStr

import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
public String buildAuthorizationStr(HttpMethodName methodName, String resouce_path,
        Map<String, String> headerMap, Map<String, String> paramMap, COSCredentials cred,
        Date expiredTime) {

    if (isAnonymous(cred)) {
        return null;
    }

    Map<String, String> signHeaders = buildSignHeaders(headerMap);
    // 签名中的参数和http 头部 都要进行字符串排序
    TreeMap<String, String> sortedSignHeaders = new TreeMap<>();
    TreeMap<String, String> sortedParams = new TreeMap<>();

    sortedSignHeaders.putAll(signHeaders);
    sortedParams.putAll(paramMap);

    String qHeaderListStr = buildSignMemberStr(sortedSignHeaders);
    String qUrlParamListStr = buildSignMemberStr(sortedParams);
    String qKeyTimeStr, qSignTimeStr;
    qKeyTimeStr = qSignTimeStr = buildTimeStr(expiredTime);
    String signKey = HmacUtils.hmacSha1Hex(cred.getCOSSecretKey(), qKeyTimeStr);
    String formatMethod = methodName.toString().toLowerCase();
    String formatUri = resouce_path;
    String formatParameters = formatMapToStr(sortedParams);
    String formatHeaders = formatMapToStr(sortedSignHeaders);

    String formatStr = new StringBuilder().append(formatMethod).append(LINE_SEPARATOR)
            .append(formatUri).append(LINE_SEPARATOR).append(formatParameters)
            .append(LINE_SEPARATOR).append(formatHeaders).append(LINE_SEPARATOR).toString();
    String hashFormatStr = DigestUtils.sha1Hex(formatStr);
    String stringToSign = new StringBuilder().append(Q_SIGN_ALGORITHM_VALUE)
            .append(LINE_SEPARATOR).append(qSignTimeStr).append(LINE_SEPARATOR)
            .append(hashFormatStr).append(LINE_SEPARATOR).toString();
    String signature = HmacUtils.hmacSha1Hex(signKey, stringToSign);

    String authoriationStr = new StringBuilder().append(Q_SIGN_ALGORITHM_KEY).append("=")
            .append(Q_SIGN_ALGORITHM_VALUE).append("&").append(Q_AK).append("=")
            .append(cred.getCOSAccessKeyId()).append("&").append(Q_SIGN_TIME).append("=")
            .append(qSignTimeStr).append("&").append(Q_KEY_TIME).append("=").append(qKeyTimeStr)
            .append("&").append(Q_HEADER_LIST).append("=").append(qHeaderListStr).append("&")
            .append(Q_URL_PARAM_LIST).append("=").append(qUrlParamListStr).append("&")
            .append(Q_SIGNATURE).append("=").append(signature).toString();
    return authoriationStr;
}
 
开发者ID:tencentyun,项目名称:cos-java-sdk-v5,代码行数:45,代码来源:COSSigner.java


注:本文中的org.apache.commons.codec.digest.DigestUtils.sha1Hex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。