PL / SQL中是否有散列函数? [英] Is there any hash function in PL/SQL?
问题描述
我正在寻找PL / SQL中的Hash函数来获取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;
/
这里是消息
Here's the message
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:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
谢谢!
Thanks!
推荐答案
确保您具有授予您要连接的用户的适当权限。与您的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中是否有散列函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!