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
Solved

sha256 for oracle

Posted on 2012-03-21
5
1,964 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 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
This video shows how to recover a database from a user managed backup
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

808 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