Adding "cryptography" custom library to Retool Workflows

Hi, when will [custom libraries in workflows] be rolled out please? I can't seem to access them...

Also why use a type form not a retool app?

Hi @mawdo81! Is there a particular library you're looking for or are you having trouble accessing the built-in libraries more generally?

Also, that's a great callout on the form :sweat_smile: We've been using typeform for a while and historically it's been a more streamlined experience for spinning up public forms specifically. It's definitely something that could be done in a Retool app though!

Thanks, it was actually one you already have, but I couldn't access the libraries as per the posts of Mar 24th. THey're there now so must have been a glitch h/deay in roll out...thanks

I can't seem to get the python cryptography library to work. Using import cryptography I get the warning

Import "cryptography" could not be resolved

That error may be misleading, what are you trying to use in the library? Would you mind sharing your code?

1 Like

Thanks!
That seems to have solved one issue by just ignoring the wanrnings! I'm importing using:

from cryptography.hazmat.primitives import serialization

And then using it in a block:

private_key_pem = """
-----BEGIN PRIVATE KEY-----
MII987654321
a1234567890A==
-----END PRIVATE KEY-----
"""
pk_bytes = private_key_pem.encode("utf-8")

# Deserialize the private key from the string
private_key = serialization.load_pem_private_key(
    pk_bytes,
    password=None
)

string_data = forSigning.data

bytes_data = string_data.encode("utf-8")
signature = rsa.sign(bytes_data, private_key, 'SHA-512')

return {signature}

But get the error:

ValueError: ('Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type (e.g. EC curves with explicit parameters).', [_OpenSSLErrorWithText(code=503841036, lib=60, reason=524556, reason_text=b'error:1E08010C:DECODER routines::unsupported')])

The same code (with the actual private key) works on my local environment (with same cryptography version, so I'm sure its not the key, just now struggling to diagnose the issue in Retool...

Hey @mawdo81! Curious to hear if you were able to resolve this issue.

If not one way to debug might be to check for any version mismatch relative to the local environment you're running. Workflows runs python 3.10.9 and cryptography 38.0.4:

Beyond that, since it looks like a library-specific error all the research I've done has been to other forums that deal with the library. Unfortunately, I haven't found anything to resolve it :pensive: but you may have more luck than I.