Java Code Examples for org.apache.commons.codec.digest.DigestUtils.shaHex()

The following are Jave code examples for showing how to use shaHex() of the org.apache.commons.codec.digest.DigestUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: KutuphaneOtomasyonSistemi   File: Controller.java   View Source Code Vote up 6 votes
@FXML
private void girisButonuTiklandi(ActionEvent event) throws IOException
{
	String username=kullaniciAdi.getText();
	String password=DigestUtils.shaHex(sifreText.getText());
	
	if(username.equals(secimler.getKullaniciadi()) && password.equals(secimler.getPassword()))
	{
		closeStage();
		loadMain();
	}
	else
	{
		Alert alert1=new Alert(Alert.AlertType.ERROR);
		alert1.setTitle("Giri� Yap�lamad�");
		alert1.setHeaderText(null);
		alert1.setContentText("Kullan�c� ad� veya �ifre hatal�");
		alert1.showAndWait();
	}
	
}
 
Example 2
Project: lams   File: BbbService.java   View Source Code Vote up 6 votes
@Override
   public String getJoinMeetingURL(UserDTO userDTO, String meetingKey, String password) throws Exception {

// Get Bbb details
String serverURL = getConfigValue(Constants.CFG_SERVER_URL);
String securitySalt = getConfigValue(Constants.CFG_SECURITYSALT);
// Get Join parameter
String joinParam = Constants.BBB_JOIN_PARAM;

if (serverURL == null) {
    BbbService.logger.error("Config item : '" + Constants.CFG_SERVER_URL + "' not defined");
    throw new BbbException("Server url not defined");
}

String queryString = "fullName="
	+ URLEncoder.encode(userDTO.getFirstName() + " " + userDTO.getLastName(), "UTF8") + "&meetingID="
	+ URLEncoder.encode(meetingKey, "UTF8") + "&password=" + URLEncoder.encode(password, "UTF8");

String checkSum = DigestUtils.shaHex("join" + queryString + securitySalt);

String url = serverURL + joinParam + queryString + "&checksum=" + checkSum;

return url;
   }
 
Example 3
Project: NetDiscovery   File: RedisQueue.java   View Source Code Vote up 6 votes
@Override
public synchronized Request poll(String spiderName) {

    Jedis jedis = pool.getResource();
    try {
        String url = jedis.lpop(getQueueKey(spiderName));
        if (url == null) {
            return null;
        }

        String key = ITEM_PREFIX + url;
        String field = DigestUtils.shaHex(url);
        byte[] bytes = jedis.hget(key.getBytes(), field.getBytes());
        if (bytes != null) {
            Request o = JSON.parseObject(new String(bytes), Request.class);
            return o;
        }

        Request request = new Request(url);
        return request;
    } finally {
        pool.returnResource(jedis);
    }
}
 
Example 4
Project: KutuphaneOtomasyonSistemi   File: Secimler.java   View Source Code Vote up 5 votes
public void setPassword(String password) {
	if(password.length()<16)
	{
	this.password =DigestUtils.shaHex(password);
	}
	else
	{
		this.password =password;
	}
}
 
Example 5
Project: VASSAL-src   File: ModuleManagerWindow.java   View Source Code Vote up 5 votes
public void cleanupTileCache() {
  final String hstr = DigestUtils.shaHex(
    metadata.getName() + "_" + metadata.getVersion()
  );

  final File tdir = new File(Info.getConfDir(), "tiles/" + hstr);
  if (tdir.exists()) {
    try {
      FileUtils.forceDelete(tdir);
    }
    catch (IOException e) {
      WriteErrorDialog.error(e, tdir);
    }
  }
}
 
Example 6
Project: VASSAL-src   File: GameModule.java   View Source Code Vote up 5 votes
public ImageTileSource getImageTileSource() {
  if (tcache == null) {
    // FIXME: There's no guarantee that getGameName() and getGameVersion()
    // are properly set at this point.

    final String hstr =
      DigestUtils.shaHex(getGameName() + "_" + getGameVersion());

    final File tc = new File(Info.getConfDir(), "tiles/" + hstr);
    tcache = new ImageTileDiskCache(tc.getAbsolutePath());
  }

  return tcache;
}
 
Example 7
Project: springboot-security-wechat   File: JsUtil.java   View Source Code Vote up 5 votes
/**
 * 生成 config接口 signature
 * @param noncestr noncestr
 * @param jsapi_ticket jsapi_ticket
 * @param timestamp timestamp
 * @param url url
 * @return sign
 */
public static String generateConfigSignature(String noncestr,String jsapi_ticket,String timestamp,String url){
	Map<String, String> map = new HashMap<String, String>();
	map.put("noncestr", noncestr);
	map.put("jsapi_ticket", jsapi_ticket);
	map.put("timestamp", timestamp);
	map.put("url", url);
	
	Map<String, String> tmap = MapUtil.order(map);
	String str = MapUtil.mapJoin(tmap,true,false);
	return DigestUtils.shaHex(str);
}
 
Example 8
Project: lams   File: BbbUtil.java   View Source Code Vote up 5 votes
public static String getMeetingKey(Long toolSessionId, String attendeePassword) {

	/*
	 * We hash the attendee's password to be used as part of the meetingKey.
	 * The main reason for this is so we can keep this unique in case there are many
	 * other instances that use the same BBB server
	 */
	return "bbb_" + DigestUtils.shaHex(attendeePassword) + "-" + toolSessionId;
    }
 
Example 9
Project: NetDiscovery   File: RedisQueue.java   View Source Code Vote up 5 votes
@Override
protected void pushWhenNoDuplicate(Request request) {

    Jedis jedis = pool.getResource();
    try {
        jedis.rpush(getQueueKey(request.getSpiderName()), request.getUrl());
        String field = DigestUtils.shaHex(request.getUrl());
        String value = JSON.toJSONString(request);
        jedis.hset((ITEM_PREFIX + request.getUrl()), field, value);
    } finally {
        jedis.close();
    }

}
 
Example 10
Project: Android_Code_Arbiter   File: WeakMessageDigest.java   View Source Code Vote up 5 votes
public static void apacheApiVariations() {

        printHex(DigestUtils.getMd2Digest().digest("123".getBytes()));
        printHex(DigestUtils.getMd5Digest().digest("123".getBytes()));
        printHex(DigestUtils.getDigest("md2").digest("123".getBytes()));
        printHex(DigestUtils.getDigest("md5").digest("123".getBytes()));
        DigestUtils.md2("123".getBytes());
        DigestUtils.md5("123".getBytes());
        System.out.println(DigestUtils.md2Hex("123".getBytes()));
        System.out.println(DigestUtils.md5Hex("123".getBytes()));

        printHex(DigestUtils.getSha1Digest().digest("123".getBytes()));
        printHex(DigestUtils.getShaDigest().digest("123".getBytes()));
        printHex(DigestUtils.getDigest("sha1").digest("123".getBytes()));
        printHex(DigestUtils.getDigest("sha-1").digest("123".getBytes()));
        DigestUtils.sha1("123".getBytes());
        DigestUtils.sha("123".getBytes());
        DigestUtils.sha1Hex("123".getBytes());
        DigestUtils.shaHex("123".getBytes());

        printHex(DigestUtils.getDigest("sha256").digest("123".getBytes())); //OK!
        printHex(DigestUtils.getDigest(getDigest()).digest("123".getBytes())); //Unknown
    }
 
Example 11
Project: ralasafe   File: ShaEncrypt.java   View Source Code Vote up 4 votes
public String encrypt( String rawTxt ) {
	if( rawTxt==null ) {
		return null;
	}
	return DigestUtils.shaHex( rawTxt );
}
 
Example 12
Project: VASSAL-src   File: TileUtils.java   View Source Code Vote up 3 votes
/**
 * Gets the name of a tile file.
 *
 * @param iname the image name
 * @param tileX the X coordinate of the tile
 * @param tileY the Y coordinate of the tile
 * @param div the scale divisor
 * @return the name of the tile file
 */
public static String tileName(String iname, int tileX, int tileY, int div) {
  final String sha = DigestUtils.shaHex(
    iname + "(" + tileX + "," + tileY + "@1:" + div
  );

  return sha.substring(0, 1) + '/' + sha.substring(0, 2) + '/' + sha;
}
 
Example 13
Project: springboot-security-wechat   File: SignatureUtil.java   View Source Code Vote up 3 votes
/**
 * 生成事件消息接收签名
 * @param token token
 * @param timestamp timestamp
 * @param nonce nonce
 * @return str
 */
public static String generateEventMessageSignature(String token, String timestamp,String nonce) {
	String[] array = new String[]{token,timestamp,nonce};
	Arrays.sort(array);
	String s = StringUtils.arrayToDelimitedString(array, "");
	return DigestUtils.shaHex(s);
}