Location: PL/SQL

Discussion: Base64 Encoding/Decoding from PL/SQLReported This is a featured thread

Showing 6 posts

sabraha5
Base64 Encoding/Decoding from PL/SQL
Jul 16 2008, 11:21 AM EDT | Post edited: Jul 16 2008, 11:21 AM EDT
Does anyone know of a way to do Base64 encoding/decoding from within PL/SQL? Thank you for your help! 4  out of 5 found this valuable. Do you?    
Keyword tags: Base64 PL/SQL PL/SQL Intro
robert.baumgartner
robert.baumgartner
1. RE: Base64 Encoding/Decoding from PL/SQL
Jul 18 2008, 2:57 AM EDT | Post edited: Jul 18 2008, 2:57 AM EDT
just load a base64 encoder java class into your database and use it...
google java base64 encode.

HTH
0  out of 1 found this valuable. Do you?    
marcelo.ochoa
marcelo.ochoa
2. RE: Base64 Encoding/Decoding from PL/SQL
Jul 18 2008, 10:37 AM EDT | Post edited: Jul 18 2008, 10:37 AM EDT
Hi:
Try doing this connected as scott:

set define ?

create or replace and compile java source named "my.Encoder" as
package my;

import sun.misc.BASE64Encoder;

public class Encoder {
static BASE64Encoder B64 = new BASE64Encoder();
public static String encodeBuffer(String buffer) {
if (buffer != null && buffer.length()>0)
return B64.encodeBuffer(buffer.getBytes());
else
return "";
}
}
/

create or replace function encodeBuffer(buffer IN VARCHAR2) return VARCHAR2 as LANGUAGE JAVA NAME
'my.Encoder.encodeBuffer(java.lang.String) return java.lang.String';
/


select encodeBuffer('scoot:tiger') from dual;


Best regards, Marcelo.
2  out of 2 found this valuable. Do you?    

sabraha5
3. RE: Base64 Encoding/Decoding from PL/SQL
Jul 22 2008, 4:25 PM EDT | Post edited: Jul 22 2008, 4:25 PM EDT
i found the UTL_ENCODE package which has BASE64_DECODE and BASE64_ENCODE functions 2  out of 3 found this valuable. Do you?    
nbertram
nbertram
4. RE: Base64 Encoding/Decoding from PL/SQL
Jul 28 2008, 2:15 AM EDT | Post edited: Jul 28 2008, 2:15 AM EDT
Yep utl_encode will do it without having to resort to Java classes. The mail demo on the Oracle site demonstrate how you can use it to send emails with attachments (base64 encoded): http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/maildemo_sql.txt

Cheers,
Niels
2  out of 2 found this valuable. Do you?    

sabraha5
5. RE: Base64 Encoding/Decoding from PL/SQL
Jul 28 2008, 6:33 AM EDT | Post edited: Jul 28 2008, 6:33 AM EDT
Hi Niels,

Thank you for your reply! I Base64 encoding/decoding was actually the least of my issues...my main problem has been trying to decrypt a DES3 encrypted file using Java API from PL/SQL using the DBMS_OBFUSCATION_TOOLKIT. I posted on the ORACLE Community Forum about my issue. It seems I can't decrypt (back to original data) the DES3 encrypted data from Java API. I thought it was issue with key generated from Java API, so I generated a key from PL/SQL...but that did not work either. I am using the javax.crypto.* package to encrypt the data...so now I am trying to import that package into an Oracle 9i database (which I have problems with also).

Sunish
0  out of 2 found this valuable. Do you?    

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)