问题描述
我正在 PL/SQL 中寻找哈希函数,以获取 varchar 的哈希.我在 Oracle 10 中找到了一个名为 dbms_crypto 的包,其中包含一个函数 dbms_crypto.hash 甚至其他包 dbms_sqlhash.getHash,但是在我调用它们的地方,我收到一条消息,就像它找不到它们一样......
I'm looking for a Hash function in PL/SQL, to get the hash of a varchar. I found a package in Oracle 10 called dbms_crypto with a function dbms_crypto.hash and even other package dbms_sqlhash.getHash, however where I called them, I've got a message like it cannot find them...
有人知道我怎么称呼他们吗??还有其他包吗?
Does somebody know how can I call them?? Is there any other package?
这是我的代码
DECLARE
l_textToHash VARCHAR2(19) := 'toto123';
l_ccn_raw RAW(128) := utl_raw.cast_to_raw(l_textToHash);
l_encrypted_raw RAW(2048);
BEGIN
dbms_output.put_line('CC: ' || l_ccn_raw);
l_encrypted_raw := dbms_crypto.hash(l_ccn_raw, 3);
dbms_output.put_line('SH1: ' || l_encrypted_raw);
END;
/
这是消息
Error starting at line 1 in command:
DECLARE
l_textToHash VARCHAR2(19) := 'toto123';
l_ccn_raw RAW(128) := utl_raw.cast_to_raw(l_textToHash);
l_encrypted_raw RAW(2048);
BEGIN
dbms_output.put_line('CC: ' || l_ccn_raw);
l_encrypted_raw := dbms_crypto.hash(l_ccn_raw, 3);
dbms_output.put_line('SH1: ' || l_encrypted_raw);
END;
Error report:
ORA-06550: line 7, column 22:
PLS-00201: identifier 'DBMS_CRYPTO' must be declared
ORA-06550: line 7, column 3:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:
%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
谢谢!
推荐答案
确保您已向与之连接的用户授予适当的权限.与您的 DBA 联系以添加对 SYS.DBMS_CRYPTO 包的执行权限.
Make sure that you have the appropriate permissions granted to the user that you are connecting with. Talk to your DBA to add the execute permission on the SYS.DBMS_CRYPTO package.
Oracle 提供了一个很好的指南 使用 oracle 数据库处理散列和加密数据.
Oracle provides a nice guide on working with hashed and encrypted data using the oracle database.
如果您使用的是不支持 DBMS_CRYPTO 的旧版本数据库,您也可以尝试 DBMS_OBFUSCATION_TOOLKIT.
If you are on an older version of the database that doesn't support DBMS_CRYPTO, you can also try DBMS_OBFUSCATION_TOOLKIT.
在 Oracle 12c 中,您可以使用函数 STANDARD_HASH.
In Oracle 12c you can use the function STANDARD_HASH.
这篇关于PL/SQL 中有散列函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!