private String calcSessionId() { try { MessageDigest md = null; SecureRandom random = new SecureRandom(); BigInteger baseCode = BigInteger.valueOf(System.nanoTime() * random.nextLong()); BigDecimal extCode = new BigDecimal(random.nextGaussian()); baseCode = baseCode.xor(extCode.toBigInteger()); byte[] base = baseCode.toByteArray(); byte[] hash; md = MessageDigest.getInstance("SHA1"); md.reset(); md.update(base); hash = md.digest(); md = null; StringBuffer resultString = new StringBuffer(); for(int i = 0; i < hash.length; i++) resultString.append(Integer.toHexString(0xF0 & hash[i]).charAt(0)); return resultString.toString(); } catch (NoSuchAlgorithmException e) { System.out.println("WTF? Cannot find SHA1 Hash-Algorithm."); } return ""; }