Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Checksum Function in PL/SQL

Posted on 1998-08-18
8
Medium Priority
?
4,786 Views
Last Modified: 2008-02-01
Hi!  Does anybody have a checksum function in PL/SQL (or algorithmn) that translates a string of text into a number ?  I prefer to use Oracle's standard function if it is accessible.  I am using this is for authentication purposes.  Thanks.
0
Comment
Question by:canlasjp
[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
8 Comments
 
LVL 2

Expert Comment

by:xiaodong
ID: 1081144
I'm not sure about your question.  What does checksum has to do with translating a string to number?  If you just want to transform a string to its corresponding hex values, then you can use the functions available in sql to do that.
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1081145
Can you be a bit more specific about what you're looking for, I can give you code to generate a CRC (not Oracle's own method) using the standard CRC algorithm or Fletcher's checksum, but I suspect that isn't what you want.
0
 

Author Comment

by:canlasjp
ID: 1081146
Xiaodong/Answers2000, I am actually looking for a CRC routine or encryption routine written in PL/SQL.   This function should take in a string as input parameter and return a number or encrypted text.  If possible, the function should work on both ASCII and EBCDIC Oracle servers.  Thanks.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:kevincristo
ID: 1081147
One other way to acheive this.
I commit the same problem, what I did is, I created a record group in design time and inserted all values with flag at run time, and I handled that values after the successful processing of some function, so as to save sequence index number.
0
 

Author Comment

by:canlasjp
ID: 1081148
Kevin, the solution you proposed will not work for me.  The function (probably server side function) should compute and return the CRC (cyclic redundancy check) number of a given character string.  

Thanks anyway.
0
 
LVL 5

Accepted Solution

by:
Mujeeb082598 earned 300 total points
ID: 1081149
Well this is a start u can use this direct or can modify as u see fit.

-----------------------------------------------------------------------
create or replace function encrypt (strin varchar2)
return number is
  strlen number(5) := nvl(length(strin),0);
  i      number(5) := 1;
  numcnt number    := 0;
  mr     number    := 155;
Begin
  for i in 1..strlen loop
    numcnt := numcnt + (ascii(substr(strin,i,1))+(162 - mr));
    mr := mr-1;
    if mr = 115 then
      mr := 155;
    end if;
  end loop;
  Return numcnt;
End;

---------------------------------------------------------------------

Output:

Select encrypt('Mujeeb-ur-Rehman') from dual;

ENCRYPT('MUJEEB-UR-REHMAN')
---------------------------
                       1756

Now u can use this number to verify what ever u want to verify.

Hope this help's.
0
 

Author Comment

by:canlasjp
ID: 1081150
Thanks Mujeeb.  This is ok but I still need to test this in an EBCDIC machine.  Can you just explain what the MR variable and its values are for ?
0
 
LVL 5

Expert Comment

by:Mujeeb082598
ID: 1081151
You are most welcome.

The MR variable is used to add extra calcutaion in the string so that one can not guess in an easy way by just adding the values one after another.

U can say it is just added salt to through someone out of the track who want to reproduce the calculated number by adding the values.

By the way MR stands for my name initials :) and the starting value if u notice is 155 which is 'r' and when it reaches 115 which again is 'M' it reset it to 155 again :) and it continues this way till whole string is calculated.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

650 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