Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 839
Cooler Avatar asked Apr 22 '26 20:04

Cooler


1 Answers

  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

like image 157
Amirhossein Farmad Avatar answered Apr 24 '26 11:04

Amirhossein Farmad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!