// Path: fernet-java8/src/main/java/com/macasaet/fernet/Constants.java
// static final Encoder encoder = getUrlEncoder();
// 
// Path: fernet-java8/src/main/java/com/macasaet/fernet/Constants.java
// static final int encryptionKeyBytes = 16;
// 
// Path: fernet-java8/src/main/java/com/macasaet/fernet/Constants.java
// static final int signingKeyBytes = 16;


import static com.macasaet.fernet.Constants.encoder;
import static com.macasaet.fernet.Constants.encryptionKeyBytes;
import static com.macasaet.fernet.Constants.signingKeyBytes;
import static nl.jqno.equalsverifier.Warning.ALL_FIELDS_SHOULD_BE_USED;
import static nl.jqno.equalsverifier.Warning.STRICT_INHERITANCE;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mutabilitydetector.unittesting.AllowedReason.allowingForSubclassing;
import static org.mutabilitydetector.unittesting.AllowedReason.assumingFields;
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf;
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;
import java.security.SecureRandom;
import java.time.Instant;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.junit.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi;

            public void nextBytes(final byte[] bytes) {
                for (int i = signingKeyBytes; --i >= 0; bytes[i] = 1);
            }
        };

        // when
        final Key result = Key.generateKey(deterministicRandom);

        // then
        final byte[] signingKey = result.getSigningKeySpec().getEncoded();
        for (int i = signingKeyBytes; --i >= 0;) {
            assertEquals(1, signingKey[i]);
        }
        final byte[] encryptionKey = result.getEncryptionKeySpec().getEncoded();
        for (int i = encryptionKeyBytes; --i >= 0;) {
            assertEquals(1, encryptionKey[i]);
        }
    }

    @Test
    public void testGetHmac() {
        // given
        final Key key = new Key("AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyA=");

        // when
        final byte[] result = key.sign((byte) 0x80, Instant.ofEpochSecond(1), new IvParameterSpec(new byte[] {2}),
                new byte[] {3});

        // then
// Path: fernet-java8/src/main/java/com/macasaet/fernet/Constants.java
// static final Encoder encoder = getUrlEncoder();
// 
// Path: fernet-java8/src/main/java/com/macasaet/fernet/Constants.java
// static final int encryptionKeyBytes = 16;
// 
// Path: fernet-java8/src/main/java/com/macasaet/fernet/Constants.java
// static final int signingKeyBytes = 16;


// Path: fernet-java8/src/test/java/com/macasaet/fernet/KeyTest.java
import static com.macasaet.fernet.Constants.encoder;
import static com.macasaet.fernet.Constants.encryptionKeyBytes;
import static com.macasaet.fernet.Constants.signingKeyBytes;
import static nl.jqno.equalsverifier.Warning.ALL_FIELDS_SHOULD_BE_USED;
import static nl.jqno.equalsverifier.Warning.STRICT_INHERITANCE;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mutabilitydetector.unittesting.AllowedReason.allowingForSubclassing;
import static org.mutabilitydetector.unittesting.AllowedReason.assumingFields;
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf;
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;
import java.security.SecureRandom;
import java.time.Instant;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.junit.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi;


            public void nextBytes(final byte[] bytes) {
                for (int i = signingKeyBytes; --i >= 0; bytes[i] = 1);
            }
        };

        // when
        final Key result = Key.generateKey(deterministicRandom);

        // then
        final byte[] signingKey = result.getSigningKeySpec().getEncoded();
        for (int i = signingKeyBytes; --i >= 0;) {
            assertEquals(1, signingKey[i]);
        }
        final byte[] encryptionKey = result.getEncryptionKeySpec().getEncoded();
        for (int i = encryptionKeyBytes; --i >= 0;) {
            assertEquals(1, encryptionKey[i]);
        }
    }

    @Test
    public void testGetHmac() {
        // given
        final Key key = new Key("AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyA=");

        // when
        final byte[] result = key.sign((byte) 0x80, Instant.ofEpochSecond(1), new IvParameterSpec(new byte[] {2}),
                new byte[] {3});

        // then
        assertEquals("WvLIvt4MSCQKgeLyvltUqN8O7mvcozhsEAgIiytxypw=", encoder.encodeToString(result));