Code example for Signature

Methods: initSign, initVerify, sign, update, verify

0
        } 
        return kp;
    } 
 
    private void test_Signature(Signature sig, KeyPair keyPair) throws Exception {
        sig.initSign(keyPair.getPrivate());
        sig.update(DATA);
        byte[] signature = sig.sign();
        assertNotNull(signature);
        assertTrue(signature.length > 0);
 
        sig.initVerify(keyPair.getPublic());
        sig.update(DATA);
        assertTrue(sig.verify(signature));
    } 
 
    private static final byte[] PK_BYTES = hexToBytes(
            "30819f300d06092a864886f70d010101050003818d0030818902818100cd769d178f61475fce3001" 
            + "2604218320c77a427121d3b41dd76756c8fc0c428cd15cb754adc85466f47547b1c85623d9c17fc6" 
            + "4f202fca21099caf99460c824ad657caa8c2db34996838d32623c4f23c8b6a4e6698603901262619" 
            + "4840e0896b1a6ec4f6652484aad04569bb6a885b822a10d700224359c632dc7324520cbb3d020301"