【发布时间】:2018-08-07 20:43:42
【问题描述】:
图书馆
create library pycryptodome
language plpythonu
from 's3://aws_python/library/pycryptodome/pycryptodome.zip'
credentials 'aws_iam_role'
region as 'aws-region';
功能
CREATE OR REPLACE FUNCTION test.aes_encrypt(input varchar(max))
RETURNS varchar(max)
STABLE
AS
'
if input is None:
return None
import pycryptodome
encrypt=True
secret_key = b''abcdefghijklmnop''
remainder = len(secret_key) % 16
modified_key = secret_key.ljust(len(secret_key) + (16 - remainder))[:32]
remainder = len(input) % 16
modified_text = input.ljust(len(input) + (16 - remainder))
cipher = pycryptodome.AES.new(modified_key, pycryptodome.AES.MODE_ECB)
return base64.b64encode(cipher.encrypt(modified_text)).strip()
'
LANGUAGE plpythonu;
我已经在 python 中测试了这段代码,它工作正常。 这里函数创建成功但是当我使用函数 test.aes_encrypt 作为 选择 test.aes_encrypt('testing') 然后它的抛出错误:
没有名为 Crypto.Cipher._mode_ecb 的模块。
请指教。
【问题讨论】:
标签: python amazon-redshift user-defined-functions