com.theicenet.cryptography.digest.DigestService Maven / Gradle / Ivy
/*
* Copyright 2019-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.theicenet.cryptography.digest;
import java.io.InputStream;
/**
* A DigestService instance is a component which produces a repeatable and deterministic
* digest value for a given content by using a cryptographic hash function.
*
* @see Cryptographic hash function
*
* @apiNote Any implementation of this interface must be unconditionally thread-safe.
*
* @author Juan Fidalgo
* @since 1.0.0
*/
public interface DigestService {
/**
* Produces the digest value of content using a cryptographic hash function.
*
* @param content content to hash to produce the digest value
* @return digest value which is the result of hashing content with a
* cryptographic hash function
*/
byte[] digest(byte[] content);
/**
* Produces the digest value of contentInputStream using a cryptographic hash
* function.
*
* @apiNote Once this method returns the input stream must have been closed so it can't be mutated.
*
* @param contentInputStream input stream with content to hash to produce the digest value
* @return digest value which is the result of hashing contentInputStream with a
* cryptographic hash function
*/
byte[] digest(InputStream contentInputStream);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy