Solved

sha256 for oracle

Posted on 2012-03-21
5
2,137 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 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 74

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

729 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