Solved

sha256 for oracle

Posted on 2012-03-21
5
1,785 Views
Last Modified: 2013-03-01
Is there sample coding using sha256 for oracle, please show me.
0
Comment
Question by:Renshi04
  • 2
5 Comments
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 500 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 73

Accepted Solution

by:
sdstuber earned 500 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now