Enum Class SupportedAlgorithm

java.lang.Object
java.lang.Enum<SupportedAlgorithm>
land.oras.utils.SupportedAlgorithm
All Implemented Interfaces:
Serializable, Comparable<SupportedAlgorithm>, Constable

@NullMarked public enum SupportedAlgorithm extends Enum<SupportedAlgorithm>
  • Enum Constant Details

  • Method Details

    • values

      public static SupportedAlgorithm[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static SupportedAlgorithm valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getPrefix

      public String getPrefix()
      Get the prefix
      Returns:
      The prefix
    • getAlgorithmName

      public String getAlgorithmName()
      Get the algorithm
      Returns:
      The algorithm
    • digest

      public String digest(byte[] bytes)
      Digest a byte array
      Parameters:
      bytes - The bytes
      Returns:
      The digest
    • digest

      public String digest(Path file)
      Digest a file
      Parameters:
      file - The file
      Returns:
      The digest
    • digest

      public String digest(InputStream inputStream)
      Digest an input stream
      Parameters:
      inputStream - The input stream
      Returns:
      The digest
    • matchPattern

      public static boolean matchPattern(String digest)
      Check if the algorithm match pattern
      Parameters:
      digest - The digest
      Returns:
      True if supported
    • isSupported

      public static boolean isSupported(String digest)
      Check if the digest is supported
      Parameters:
      digest - The digest
      Returns:
      True if supported
    • fromDigest

      public static SupportedAlgorithm fromDigest(String digest)
      Get the algorithm from a digest
      Parameters:
      digest - The digest
      Returns:
      The algorithm
    • getDefault

      public static SupportedAlgorithm getDefault()
      Get the default algorithm
      Returns:
      The default algorithm
    • getDigest

      public static String getDigest(String digest)
      Return the digest without the prefix
      Parameters:
      digest - The digest
      Returns:
      The digest without the prefix