java/src/main/java/com/alexa/awisapi/AWIS.java [108:143]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  String sha256(String textToHash) throws Exception {
      MessageDigest digest = MessageDigest.getInstance("SHA-256");
      byte[] byteOfTextToHash=textToHash.getBytes("UTF-8");
      byte[] hashedByteArray = digest.digest(byteOfTextToHash);
      return bytesToHex(hashedByteArray);
  }

  static byte[] HmacSHA256(String data, byte[] key) throws Exception {
      Mac mac = Mac.getInstance(HASH_ALGORITHM);
      mac.init(new SecretKeySpec(key, HASH_ALGORITHM));
      return mac.doFinal(data.getBytes("UTF8"));
  }

  public static String bytesToHex(byte[] bytes) {
      StringBuffer result = new StringBuffer();
      for (byte byt : bytes) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
      return result.toString();
  }

  /**
   * Generates a V4 Signature key for the service/region
   *
   * @param key         Initial secret key
   * @param dateStamp   Date in YYYYMMDD format
   * @param regionName  AWS region for the signature
   * @param serviceName AWS service name
   * @return byte[] signature
   * @throws Exception
   */
  static byte[] getSignatureKey(String key, String dateStamp, String regionName, String serviceName) throws Exception {
      byte[] kSecret = ("AWS4" + key).getBytes("UTF8");
      byte[] kDate = HmacSHA256(dateStamp, kSecret);
      byte[] kRegion = HmacSHA256(regionName, kDate);
      byte[] kService = HmacSHA256(serviceName, kRegion);
      byte[] kSigning = HmacSHA256("aws4_request", kService);
      return kSigning;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



legacy/java/UrlInfo.java [58:93]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    String sha256(String textToHash) throws Exception {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        byte[] byteOfTextToHash=textToHash.getBytes("UTF-8");
        byte[] hashedByteArray = digest.digest(byteOfTextToHash);
        return bytesToHex(hashedByteArray);
    }

    static byte[] HmacSHA256(String data, byte[] key) throws Exception {
        Mac mac = Mac.getInstance(HASH_ALGORITHM);
        mac.init(new SecretKeySpec(key, HASH_ALGORITHM));
        return mac.doFinal(data.getBytes("UTF8"));
    }

    public static String bytesToHex(byte[] bytes) {
        StringBuffer result = new StringBuffer();
        for (byte byt : bytes) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
        return result.toString();
    }

    /**
     * Generates a V4 Signature key for the service/region
     *
     * @param key         Initial secret key
     * @param dateStamp   Date in YYYYMMDD format
     * @param regionName  AWS region for the signature
     * @param serviceName AWS service name
     * @return byte[] signature
     * @throws Exception
     */
    static byte[] getSignatureKey(String key, String dateStamp, String regionName, String serviceName) throws Exception {
        byte[] kSecret = ("AWS4" + key).getBytes("UTF8");
        byte[] kDate = HmacSHA256(dateStamp, kSecret);
        byte[] kRegion = HmacSHA256(regionName, kDate);
        byte[] kService = HmacSHA256(serviceName, kRegion);
        byte[] kSigning = HmacSHA256("aws4_request", kService);
        return kSigning;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



