public abstract class Signature extends Object:
Abstract base class for digital signatures.
The concrete RSA APIs are exposed through RSAPSSSignature and RSAPKCS1Signature, parameterized by a concrete digest such as SHA256() or SHA512().
import klyn.cryptography
keys = RSAKeyPairGenerator().generateKeyPair()
signer as Signature = RSAPSSSignature(SHA256())
signer.initSign(keys.privateKeyPem)
token = signer.sign("hello")
verifier as Signature = RSAPSSSignature(SHA256())
verifier.initVerify(keys.publicKeyPem)
print(verifier.verify(token, "hello"))| Modifier and Type | Member | Description |
|---|---|---|
| public readonly | algorithmalgorithm as String |
Canonical signature algorithm name. |
| public readonly | hashAlgorithmhashAlgorithm as String |
Canonical digest algorithm name used by the signature. |
| public readonly | paddingpadding as String |
RSA padding mode used by the signature. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | getInstancegetInstance(algorithm as String) as Signature throws CryptoException: |
Compatibility factory for dynamic algorithm selection. |
| public | initSigninitSign(privateKeyPem as String) as Void: |
Initializes the instance for signing with a private key. |
| public | initVerifyinitVerify(publicKeyPem as String) as Void: |
Initializes the instance for verification with a public key. |
| public | resetreset() as Void: |
Clears the buffered text accumulated with `update`. |
| public | signsign(text as String = null, outputEncoding as String = "base64") as String throws CryptoException: |
Signs the buffered text and an optional final chunk. |
| public override | toStringtoString() as String: |
No summary. |
| public | update | Appends text to the in-memory signature buffer. |
| public | verifyverify(signature as String, text as String = null, inputEncoding as String = "base64") as Boolean throws CryptoException: |
Verifies a signature against the buffered text and an optional final chunk. |