Main.webfleet_ws_key_generation - webfleet_ws_key_generation 
Page of - last modified by Admin on 2019/09/10 07:01 
webfleet_ws_key_generation 

Admin

2019/09/10 07:01
Table of Contents

To generate key you need to know account's username and password.
Using SHA-1 algorithm hash text "username;password;unixTime" and convert to hex string
Concat hex string and unixTime value with delimiter ';' in one String
Example:
Username = "foo"
Password = "bar"
UnixTime = 1429860412
key = sha1Hex("foo;bar;1429860412")+";"+"1429860412"
Resulting key example: f083777d2eaf876eca37e43e927702b4ed15d42d;1429860412
Key generation code in java

 private MessageDigest messageDigest = DigestUtils.getSha1Digest();

 public String makeKeyFor(String username, String password) {
      DateTime now = DateTime.now(DateTimeZone.forID("UTC"));
      int unixTime = (int) (now.getMillis() / 1000);

      String unencryptedKey = String.format("%s;%s;%s", username, password, unixTime);
      return sha1Hex(unencryptedKey) + ";" + unixTime;
  }

 private String sha1Hex(String input) {
        return Hex.encodeHexString(messageDigest.digest(input.getBytes()));
  }