Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sha256 for oracle

Posted on 2012-03-21
5
Medium Priority
?
2,414 Views
Last Modified: 2013-03-01
Is there sample coding using sha256 for oracle, please show me.
0
Comment
Question by:Renshi04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 2000 total points
ID: 37752674
there is no built in sha256 in Oracle,  dbms_crypto only has sha-1  support.

You could use a java stored procedure though
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 37752944
The java might looks something like this...
for production use you'll probably want to include some exception handlers but this is the core of it.


CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED sha256 AS
import java.security.MessageDigest;
import oracle.sql.*;

public class sha256
{
   public static oracle.sql.RAW get_digest( String p_string ) throws Exception
   {
      MessageDigest v_md = MessageDigest.getInstance( "SHA-256" );
      byte[] v_digest;
      v_digest = v_md.digest( p_string.getBytes( "UTF-8" ) );
      return RAW.newRAW(v_digest);
   }  
}
/


CREATE OR REPLACE FUNCTION sha256_digest(p_string VARCHAR2)
    RETURN RAW
AS
    LANGUAGE JAVA
    NAME 'sha256.get_digest( java.lang.String ) return oracle.sql.RAW';
/


SELECT sha256_digest('this is my test string') FROM DUAL;
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows how to recover a database from a user managed backup
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question