type

PrivKey

src const mixin PrivKey : AsymKey

A private key in an asymmetric key pair. A private key can be used to sign and decrypt data.

methods

decrypt

Decrypt the contents of the data buffer and return the result.

sign

Sign the contents of the data buffer after applying the given digest algorithm and return the signature.

Slot Details

decrypt

src abstract Buf decrypt(Buf data, Str padding := "PKCS1Padding")

Decrypt the contents of the data buffer and return the result. Throws Err if the decryption fails for any reason.

msg := privKey.decrypt(encrypted)

sign

src abstract Buf sign(Buf data, Str digest)

Sign the contents of the data buffer after applying the given digest algorithm and return the signature. Throws Err if the digest algorithm is not supported.

signature := privKey.sign("Message".toBuf, "SHA512")