2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.io.imperihome.internal.util;
15 import java.math.BigInteger;
16 import java.nio.charset.StandardCharsets;
17 import java.security.MessageDigest;
18 import java.security.NoSuchAlgorithmException;
23 * @author Pepijn de Geus - Initial contribution
25 public final class DigestUtil {
27 public static String sha1(String input) {
29 MessageDigest crypt = MessageDigest.getInstance("SHA-1");
31 crypt.update(input.getBytes(StandardCharsets.UTF_8));
33 return new BigInteger(1, crypt.digest()).toString(16);
34 } catch (NoSuchAlgorithmException e) {
35 throw new RuntimeException("Could not generate SHA-1 hash", e);
40 private DigestUtil() {