熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

ORACLE 應用經驗(4)-加密程序

2022-06-13   來源: Oracle 

   加密程序數據庫觸發子scjmmm
  REM 對GHXXB制立數據庫觸發子(當INSERT OR UPDATE GHXXB時觸發)
  drop trigger scjmmm;
  create or replace trigger scjmmm
  before insert or update of mm On ghxxb For each Row
  Begin
  :newmm:=ENCRYPT(:newmm:NEWGHTO_CHAR(SYSDATESS));
  End;
  /
   密碼的加密程序ENCRYPT
  Create or Replace
  Function ENCRYPT (Inpass In VarcharIN_GH In VarcharIN_SS In Varchar)
  Return Varchar Is
  bcs varchar();
  bcs number;
  cs number;
  jg number;
  m_gh VARCHAR();
  m_mm VARCHAR();
  Begin
  m_gh:=IN_GH;
  m_mm:=INPASS;
  cs:=TO_NUMBER(IN_SS);
  If cs<=1 then cs:=77 ;end if;
  bcs:=substr(to_char(ascii(substr(m_gh,1,1))),1,2);
  If bcs<'1' then bcs:='7' ;end if;
  m_gh:=substr(m_gh,2);
  Loop EXIT WHEN nvl(length(m_gh),0)=0 ;
  bcs:=bcs||substr(to_char(ascii(substr(m_gh,1,1))),-1,1);
  m_gh:=substr(m_gh,2);
  End loop;
  Loop EXIT WHEN nvl(length(m_mm),0)=0 ;
  bcs:=bcs||substr(to_char(ascii(substr(m_mm,1,1))),-1,1);
  m_mm:=substr(m_mm,2);
  End loop;
  bcs1:=to_number(bcs);
  jg:=cs*bcs1;
  Loop EXIT WHEN length(to_char(jg))>13;
  jg:=jg*cs ;
  End loop;
  RETURN(IN_SS||substr(to_char(jg),1,14));
  End;
  /
  grant execute on ENCRYPT to public;
  
  
  
  
  

From:http://tw.wingwit.com/Article/program/Oracle/201311/11194.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.