ch.openchvote.utilities.crypto.HashAlgorithm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utilities Show documentation
Show all versions of utilities Show documentation
This module provides a collection of utility classes, especially for various mathematical concepts.
The newest version!
/*
* Copyright (C) 2024 Berner Fachhochschule https://e-voting.bfh.ch
*
* - This program is free software: you can redistribute it and/or modify -
* - it under the terms of the GNU Affero General Public License as published by -
* - the Free Software Foundation, either version 3 of the License, or -
* - (at your option) any later version. -
* - -
* - This program is distributed in the hope that it will be useful, -
* - but WITHOUT ANY WARRANTY; without even the implied warranty of -
* - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -
* - GNU General Public License for more details. -
* - -
* - You should have received a copy of the GNU Affero General Public License -
* - along with this program. If not, see . -
*/
package ch.openchvote.utilities.crypto;
import ch.openchvote.utilities.sequence.ByteArray;
/**
* This interface defines the functionality of a cryptographic hash function, which operates on byte arrays.
* Instantiations of this interface can be used for computing hash values of string messages.
*/
public interface HashAlgorithm {
/**
* The default SHA3 instantiation of this interface.
*/
HashAlgorithm SHA3 = new SHA3();
/**
* Returns the algorithm's hash length (number of bytes).
*
* @return The hash length
*/
int getLength();
/**
* Returns the hash value of the input message. Both the message and the resulting hash value are instances of the
* class {@link ByteArray}.
*
* @param message The message to hash
* @return The resulting hash value
*/
ByteArray hash(ByteArray message);
}