public final void init(Key key) throws InvalidKeyException {
        try {
            if (spi != null && (key == null || lock == null)) {
                spi.engineInit(key, null);
            } else {
                chooseProvider(key, null);
            }
        } catch (InvalidAlgorithmParameterException e) {
            throw new InvalidKeyException("init() failed", e);
        }
        initialized = true;

        /* Android-removed: this debugging mechanism is not used in Android.
        if (!skipDebug && pdebug != null) {
            pdebug.println("Mac." + algorithm + " algorithm from: " +
                this.provider.getName());
        }
        */
    }
public final void init ( Key key ) throws InvalidKeyException { try { if ( spi != null && ( key == null || lock == null ) ) { spi . engineInit ( key , null ) ; } else { chooseProvider ( key , null ) ; } } catch ( InvalidAlgorithmParameterException e ) { throw new InvalidKeyException ( "init() failed" , e ) ; } initialized = true ; }
Initializes this <code>Mac</code> object with the given key.

@param key the key.

@exception InvalidKeyException if the given key is inappropriate for
initializing this MAC.