DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: encryption and decryption of spl chars

  1. #1
    Join Date
    Sep 2002
    Posts
    376

    encryption and decryption of spl chars

    hi,

    I have a string of Special characters.
    I need to encrypt each of the special character to another value in the string, without repeatation, so that i can decrypt it back, for a particular seed value.


    string_val=$%&()~'*,-/:;=?_

    substr(string_val, mod (instr(string_val,curr_char) + 545,length(string_val)),1)

    Curr_char is the value passed to get the encrypted one.

    I am getting repeations (for eg., * and , are getting encrypted to $) due to which i am not able to decrypt.

    can somebody suggest changes to the above query, so that there wont be any repeatations.

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166

    Re: encryption and decryption of spl chars

    Why don't you just use the Obfuscation Toolkit?

  3. #3
    Join Date
    Sep 2002
    Posts
    376
    Due to some bottlenecks in the application, i cannot use it.
    I want a common algorith, which works same in front end and back end.

  4. #4
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Your problem is that MOD( , n) gives values from 0 to n-1 and SUBSTR(x, 0, 1) is interpreted as SUSBTR(x, 1, 1). Check with this
    Code:
    declare
    	string_val varchar(30) := '$%&()~''*,-/:;=?_';
    	curr_char  varchar(1);
    	out_line   varchar(100);
    begin
    	for i in 1..length(string_val) loop
    		curr_char := substr(string_val, i, 1);
    		out_line  := curr_char||' gives '||
    			substr(string_val, mod (instr(string_val,curr_char) + 545,length(string_val))+1,1);
    		dbms_output.put_line(out_line);
    	end loop;
    end;
    /
    P.S. mod(545,16)=1 why be so complicated?
    Last edited by DaPi; 05-05-2005 at 06:18 PM.
    "The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman

  5. #5
    Join Date
    Sep 2002
    Posts
    376
    Thx Dapi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width