Sunday, May 27, 2012

Hiding a button in Oracle Apex

There may be a situations where you want to hide a button without removing it or making it's Condition = Never.

Simply add the following: style="display:none" to Button's attribute to accomplish this.

Saturday, May 26, 2012

Hashing passwords in Oracle Database using MD5

When building applications (especially with Oracle Apex) we often have the requirement for managing users with a decent authentication system set up. A security consideration here is hashing password.

You can use the following function to hash your password using MD5.

However if you recursively hash it several times, you can secure your application and prevent dictionary attacks.

Here is a very simple function I wrote for this purpose.



create or replace Function hashPass
   ( raw_pass IN varchar2 )
   RETURN varchar2
IS
    I NUMBER;
    RES VARCHAR2(500);
BEGIN
    res:=raw_pass; -- start by putting raw value into result

    FOR I IN 1..95 LOOP -- hash it 95 times to prevent dictionary attacks
        SELECT WWV_FLOW_ITEM.MD5(res) into res FROM DUAL;
    END LOOP;

    RETURN RES; -- return hash
END;




Note: 
  1. Hashing with MD5 once is never secure as there is possibility of dictionary attacks.
  2. I used 95 times for my example. You may use any arbitrary number. 

Sunday, May 20, 2012

Oracle Apex: Resizing an image (BLOB) in interactive report

If you are putting an image in one of your columns in an interactive/classic report, you may want to reduce them all to same size or make the oversized images appear smaller.

Simply add this CSS to your page HTML header section:

<style type="text/css">

.apexir_WORKSHEET_DATA  td[headers="IMG_COL"] img
{

  width: 100px;
  height: 100px; 
}

</style>

Replace IMG_COL with the name of the BLOB column holding the image.

Note: This may not work with Internet Explorer.

Monday, May 7, 2012

Finding a text in files in linux

To search for a text in a bunch of files in a directory in Linux use grep command recursively as below:

$ grep -irn "text" /home/ai 

This will search for the word "text" in all files in home directory and all sub directories.

The -i asks it to ignore case.
The -r lets grep dig into the directory and all sub-directories recursively.
The -n outputs the line number when the match is found.