Class CcXor

  • All Implemented Interfaces:
    Codec

    public final class CcXor
    extends Object
    implements Codec
    XOR codec.

    The class is immutable and thread-safe.

    Since:
    0.1
    • Constructor Detail

      • CcXor

        public CcXor​(Codec codec,
                     String key)
        Ctor.
        Parameters:
        codec - Original codec
        key - Secret key for encoding
      • CcXor

        public CcXor​(Codec codec,
                     byte[] key)
        Ctor.
        Parameters:
        codec - Original codec
        key - Secret key for encoding
    • Method Detail

      • encode

        public byte[] encode​(Identity identity)
                      throws IOException
        Description copied from interface: Codec
        Encode identity into bytes.
        Specified by:
        encode in interface Codec
        Parameters:
        identity - The identity
        Returns:
        Text
        Throws:
        IOException - If fails
      • decode

        public Identity decode​(byte[] bytes)
                        throws IOException
        Description copied from interface: Codec
        Decode identity from text (or throw DecodingException).

        This method may throw DecodingException, if it's not possible to decode the incoming byte array. This exception will mean that the user can't be authenticated and Identity.ANONYMOUS object will be identified.

        Specified by:
        decode in interface Codec
        Parameters:
        bytes - Text
        Returns:
        Identity
        Throws:
        IOException - If fails