# Class Signature

java.lang.Object
com.codename1.security.Signature

public final class Signature extends Object

Digital signature creation and verification. Backed by the platform's native crypto provider -- works with `PublicKey` / `PrivateKey` objects from this package.

##### Example: sign with RSA-SHA-256 and verify

    KeyPair kp = KeyGenerator.rsa(2048);
    byte[] sig = Signature.sign(Signature.SHA256_WITH_RSA, kp.getPrivateKey(), data);
    boolean ok = Signature.verify(Signature.SHA256_WITH_RSA, kp.getPublicKey(), data, sig);

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `SHA256_WITH_ECDSA`
  `SHA256withECDSA` -- ECDSA with SHA-256 (P-256 curve).
  `static final String`
  `SHA256_WITH_RSA`
  `SHA256withRSA` -- RSA PKCS#1 v1.5 with SHA-256.
  `static final String`
  `SHA384_WITH_ECDSA`
  `SHA384withECDSA` -- ECDSA with SHA-384 (P-384 curve).
  `static final String`
  `SHA384_WITH_RSA`
  `SHA384withRSA` -- RSA PKCS#1 v1.5 with SHA-384.
  `static final String`
  `SHA512_WITH_ECDSA`
  `SHA512withECDSA` -- ECDSA with SHA-512 (P-521 curve).
  `static final String`
  `SHA512_WITH_RSA`
  `SHA512withRSA` -- RSA PKCS#1 v1.5 with SHA-512.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static byte[]`
  `sign(String algorithm, PrivateKey key, byte[] data)`
  Signs `data` with the given algorithm and private key.
  `static boolean`
  `verify(String algorithm, PublicKey key, byte[] data, byte[] signature)`
  Verifies `signature` against `data` using the given algorithm and public key.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### SHA256_WITH_RSA

    public static final String SHA256_WITH_RSA
    `SHA256withRSA` -- RSA PKCS#1 v1.5 with SHA-256.
    See Also:
      - Constant Field Values

  - ### SHA384_WITH_RSA

    public static final String SHA384_WITH_RSA
    `SHA384withRSA` -- RSA PKCS#1 v1.5 with SHA-384.
    See Also:
      - Constant Field Values

  - ### SHA512_WITH_RSA

    public static final String SHA512_WITH_RSA
    `SHA512withRSA` -- RSA PKCS#1 v1.5 with SHA-512.
    See Also:
      - Constant Field Values

  - ### SHA256_WITH_ECDSA

    public static final String SHA256_WITH_ECDSA
    `SHA256withECDSA` -- ECDSA with SHA-256 (P-256 curve).
    See Also:
      - Constant Field Values

  - ### SHA384_WITH_ECDSA

    public static final String SHA384_WITH_ECDSA
    `SHA384withECDSA` -- ECDSA with SHA-384 (P-384 curve).
    See Also:
      - Constant Field Values

  - ### SHA512_WITH_ECDSA

    public static final String SHA512_WITH_ECDSA
    `SHA512withECDSA` -- ECDSA with SHA-512 (P-521 curve).
    See Also:
      - Constant Field Values

- ## Method Details

  - ### sign

    public static byte[] sign(String algorithm, PrivateKey key, byte[] data)
    Signs `data` with the given algorithm and private key.

  - ### verify

    public static boolean verify(String algorithm, PublicKey key, byte[] data, byte[] signature)
    Verifies `signature` against `data` using the given algorithm and public key.