Как мне насытить криптопримитива

#java

Вопрос:

Таким образом, в основном я получил этот файл, и я изо всех сил пытаюсь понять, как создать экземпляр cryptoprimitve, а также тот факт, что я не уверен, что правильно определил криптопримитив. не мог бы кто-нибудь, пожалуйста, помочь

 import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.CryptoPrimitive;
import java.security.DigestException;
import java.security.NoSuchAlgorithmException;


/**
 * Program to calculate a SHA-512 (or other) digest over a file
 */

/**
 * @author 
 *
 */
public class Digest {
    
    private static final String progName = "Digest";        // Name of the program
    private static final int bufSize = 512;                 // Almost any sensible value will work here

    /**
     * @param args
     */
    public static void main(String[] args) {

        BufferedInputStream in = null;          // A buffered input stream to read from
        byte[] inputBuffer = new byte[bufSize]; // A buffer for the input read from the file
        int bytesRead = 0;                      // Number of bytes read into the input file buffer
        byte[] messageDigest = null;            // A variable for the actual digest value, as an array of bytes
        
        // First, check the user has provided all the required arguments, and if they haven't, tell them then exit
        if(args.length != 1) {
            printUsageMessage(); System.exit(1);
        }

        // Open the input file
        try {
            in = new BufferedInputStream(new FileInputStream(args[0]));
        } catch (FileNotFoundException e) {
            printErrorMessage("Unable to open input file: "   args[0], null);
            System.exit(1);
        }
        
        // Define a variable for the required Cryptoprimitives

        CryptoPrimitive sha = null;
        
        // Now, instantiate the required cryptoprimitive
 

Комментарии:

1. CryptoPrimitive это перечисление , вы не создаете его, вы используете его, например CryptoPrimitive.MESSAGE_DIGEST . — Это похоже на проблему XY . Что вы на самом деле пытаетесь здесь сделать? Почему вы считаете, что вам нужно создать экземпляр a CryptoPrimitive ? — Я много раз делал дайджесты сообщений на Java, но никогда CryptoPrimitive ими не пользовался , поэтому мне любопытно, почему вы думаете, что вам это нужно.