我需要通过Oracle检查sha512加密中的数据。
示例查询:
SELECT * FROM text WHERE SHA512(id) = '$id'发布于 2015-04-08 10:39:00
Oracle提供了处理加密和散列的DBMS_CRYPTO包。
您可以以如下查询所示的方式将SHA哈希计算和比较与某些字符串常量结合起来:
select *
from text t
where
lower( -- to guarantee same character case
rawtohex( -- convert hash to string representation
dbms_crypto.hash( -- hash calculation function
utl_raw.cast_to_raw(t.id), -- need to convert a string before passing it to
-- function in parameter because otherwise
-- it casted to RAW directly with hextoraw().
6 -- dbms_crypto.HASH_SH512 - for Oracle 12c only
)
)
)
=
lower( -- to guarantee same character case
:some_id_sha2_const_parameter -- parameter string to compare with
) 不幸的是,由于缺乏支持,您无法处理Oracle11g中的SHA-512散列。但甲骨文12c是有可能的。
文档:
还有两件事你必须考虑到:
https://stackoverflow.com/questions/29510413
复制相似问题