The str  length cannot be greater than the key_str  length −  11, in bytes 

key_str  must be a valid key string in PEM format. algorithm  indicates the encryption algorithm used to create the key. 

Supported algorithm  values: ’RSA’ 

To encrypt a string, pass a private or public key string to asymmetric_encrypt() . To recover the original unencrypted string, pass the encrypted string to asymmetric_decrypt() , along with the public or private key string correponding to the private or public key string used for encryption. 

-- Generate private/public key pair SET @priv = create_asymmetric_priv_key(’RSA’, 1024); SET @pub = create_asymmetric_pub_key(’RSA’, @priv); -- Encrypt using private key, decrypt using public key SET @ciphertext = asymmetric_encrypt(’RSA’, ’The quick brown fox’, @priv); SET @plaintext = asymmetric_decrypt(’RSA’, @ciphertext, @pub); -- Encrypt using public key, decrypt using private key SET @ciphertext = asymmetric_encrypt(’RSA’, ’The quick brown fox’, @pub); SET @plaintext = asymmetric_decrypt(’RSA’, @ciphertext, @priv); 

Suppose that: 

SET @s = a string to be encrypted SET @priv = a valid private RSA key string in PEM format SET @pub = the corresponding public RSA key string in PEM format 

Then these identity relationships hold: 

asymmetric_decrypt(’RSA’, asymmetric_encrypt(’RSA’, @s, @priv), @pub) = @s asymmetric_decrypt(’RSA’, asymmetric_encrypt(’RSA’, @s, @pub), @priv) = @s 

• asymmetric_sign( algorithm , digest_str , priv_key_str , digest_type ) 

Signs a digest string using a private key string, and returns the signature as a binary string. If signing fails, the result is NULL . 

digest_str  is the digest string. It can be generated by calling create_digest() . digest_type indicates the digest algorithm used to generate the digest string. 

priv_key_str  is the private key string to use for signing the digest string. It must be a valid key string in PEM format. algorithm  indicates the encryption algorithm used to create the key. 

Supported algorithm  values: ’RSA’ , ’DSA’ 

Supported digest_type  values: ’SHA224’ , ’SHA256’ , ’SHA384’ , ’SHA512’ 

For a usage example, see the description of asymmetric_verify() . 

