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 Details

    • SHA256_WITH_RSA

      public static final String SHA256_WITH_RSA
      SHA256withRSA -- RSA PKCS#1 v1.5 with SHA-256.
      See Also:
    • SHA384_WITH_RSA

      public static final String SHA384_WITH_RSA
      SHA384withRSA -- RSA PKCS#1 v1.5 with SHA-384.
      See Also:
    • SHA512_WITH_RSA

      public static final String SHA512_WITH_RSA
      SHA512withRSA -- RSA PKCS#1 v1.5 with SHA-512.
      See Also:
    • SHA256_WITH_ECDSA

      public static final String SHA256_WITH_ECDSA
      SHA256withECDSA -- ECDSA with SHA-256 (P-256 curve).
      See Also:
    • SHA384_WITH_ECDSA

      public static final String SHA384_WITH_ECDSA
      SHA384withECDSA -- ECDSA with SHA-384 (P-384 curve).
      See Also:
    • SHA512_WITH_ECDSA

      public static final String SHA512_WITH_ECDSA
      SHA512withECDSA -- ECDSA with SHA-512 (P-521 curve).
      See Also:
  • 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.