问题
I'm working on REST API authorization in PL/SQL using Oracle database 11g Express Edition. I have api_key, nonce and signature as IN variables for every procedure.
Signature is a HMAC-SHA256 encoded string containing api_secret stored in my database. I want check if signature matching my api_secret in database.
My question is how can I encode string in HMAC-SHA256 using pl/sql?
回答1:
There is SHA256 PL/SQL Implementation for Oracle 10g,11g by CruiserX. Download the package from here.
Compile the package and package body in sqlplus.
Call the functions like this:
SQL> select sha256.encrypt('test message') from dual;
-- output: 3f0a377ba0a4a460ecb616f6507ce0d8cfa3e704025d4fda3ed0c5ca05468728
SQL> select sha256.encrypt_raw('74657374206D657373616765') from dual;
-- output: 3f0a377ba0a4a460ecb616f6507ce0d8cfa3e704025d4fda3ed0c5ca05468728
来源:https://stackoverflow.com/questions/36692999/how-can-i-encode-string-in-hmac-sha256-using-pl-sql