how can I encode string in HMAC-SHA256 using pl/sql?

杀马特。学长 韩版系。学妹 提交于 2020-01-23 12:35:48

问题


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:


  1. There is SHA256 PL/SQL Implementation for Oracle 10g,11g by CruiserX. Download the package from here.

  2. Compile the package and package body in sqlplus.

  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!