Class AbstractEncoder

    • Constructor Detail

      • AbstractEncoder

        public AbstractEncoder​(String id)
    • Method Detail

      • decode

        public byte[] decode​(byte[] toDecode,
                             byte[] salt,
                             byte[] passphrase,
                             String charset)
                      throws EncoderException
        Description copied from interface: Encoder
        Decode bytes (if supported) to text.
        Specified by:
        decode in interface Encoder
        Parameters:
        toDecode - bytes to decode
        salt - TODO
        passphrase - passphrase if supported
        charset - character set
        Returns:
        decoded text
        Throws:
        EncoderException - if encoding fails
      • getId

        public String getId()
        Description copied from interface: Encoder
        Get the ID of this encoder.
        Specified by:
        getId in interface Encoder
        Returns:
        id
      • isOfType

        public boolean isOfType​(byte[] encodedBytes,
                                String charset)
        Description copied from interface: Encoder
        Determine if this encoder may have been used to create the provided encoded bytes. This method should only be used if it is very likely to be the right encoder.
        Specified by:
        isOfType in interface Encoder
        Parameters:
        encodedBytes - encoded bytes
        charset - character set
        Returns:
        this almost certainly was encoded with a similar encoder
      • match

        public boolean match​(byte[] encodedData,
                             byte[] unencodedData,
                             byte[] passphrase,
                             String charset)
        Description copied from interface: Encoder
        Check if the provide un-encoded data would match the encoded data if it was encoded.
        Specified by:
        match in interface Encoder
        Parameters:
        encodedData - encoded data
        unencodedData - un-encoded data
        passphrase - passphrase if supported
        charset - character set
        Returns:
        matches
      • randomBytes

        protected byte[] randomBytes​(int count)