Package javax.crypto

Examples of javax.crypto.Mac.doFinal()


        //
        mac.init(key);

        mac.update(input, 0, input.length);

        out = mac.doFinal();

        if (!areEqual(out, output1))
        {
            fail("Failed - expected " + new String(Hex.encode(output1)) + " got " + new String(Hex.encode(out)));
        }
View Full Code Here


        //
        mac.init(key, new IvParameterSpec(ivBytes));

        mac.update(input, 0, input.length);

        out = mac.doFinal();

        if (!areEqual(out, output2))
        {
            fail("Failed - expected " + new String(Hex.encode(output2)) + " got " + new String(Hex.encode(out)));
        }
View Full Code Here

        mac.init(key, new IvParameterSpec(ivBytes));

        mac.update(input, 0, input.length);

        out = mac.doFinal();

        if (!areEqual(out, output3))
        {
            fail("Failed - expected " + new String(Hex.encode(output3)) + " got " + new String(Hex.encode(out)));
        }
View Full Code Here

        mac.init(key);

        mac.update(inputISO9797, 0, inputISO9797.length);

        out = mac.doFinal();

        if (!areEqual(out, outputISO9797))
        {
            fail("Failed - expected " + new String(Hex.encode(outputISO9797)) + " got " + new String(Hex.encode(out)));
        }
View Full Code Here

        mac.init(key);

        mac.update(inputDesEDE64, 0, inputDesEDE64.length);

        out = mac.doFinal();

        if (!areEqual(out, outputDesEDE64))
        {
            fail("Failed - expected " + new String(Hex.encode(outputDesEDE64)) + " got " + new String(Hex.encode(out)));
        }
View Full Code Here

        mac.reset();
       
        mac.update(message, 0, message.length);

        out = mac.doFinal();

        if (!Arrays.areEqual(out, output))
        {
            fail("Failed - expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
        }
View Full Code Here

        mac.reset();

        mac.update(message, 0, message.length);

        out = mac.doFinal();

        if (!Arrays.areEqual(out, output))
        {
            fail("Failed - expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
        }
View Full Code Here

            Mac mac = Mac.getInstance(name);

            mac.init(new SecretKeySpec(new byte[mac.getMacLength()], mac.getAlgorithm()), new IvParameterSpec(
                new byte[16]));
            mac.update(new byte[128]);
            byte[] bytes = mac.doFinal();

            if (!Arrays.areEqual(bytes, Hex.decode(macOutput)))
            {
                fail("wrong mac value computed for " + name);
            }
View Full Code Here

            final Mac mac = Mac.getInstance(SIGNATURE_ALGORITHM);
            mac.init(signingKey);

            // BASE64Encoder isn't technically a public class, but it
            // has been consistently available in Java releases to date
            auth = Base64.encodeBytes(mac.doFinal(buf.toString().getBytes()));
        }
        catch(Exception e) {
            throw new IllegalArgumentException("Unable to calculate digest", e);
        }
View Full Code Here

            SecretKey sk = new SecretKeySpec( key, "AES" );

            Mac mac = Mac.getInstance( "HmacSHA1" );
            mac.init( sk );

            return mac.doFinal( data );
        }
        catch ( GeneralSecurityException nsae )
        {
            nsae.printStackTrace();
            return null;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.