Omar Kh

Omar Kh

  • NA
  • 301
  • 21.8k

how to encrypt string using AES 128 bit in c#?

Sep 17 2020 3:52 AM
I'm working on web application in asp.net with oracle Database12c I'm using aes128 stored procedure to encrypt the password here is the procedure that makes encryption
  1. SET SERVEROUTPUT ON;    
  2.     
  3. DECLARE    
  4.    l_user_id    test.username%TYPE := 'SCOTT';    
  5.    l_user_psw   VARCHAR2 (2000) := 'mypassword123';    
  6.     
  7.    l_key        VARCHAR2 (2000) := '1234567890999999';    
  8.    l_mod NUMBER    
  9.          :=   DBMS_CRYPTO.ENCRYPT_AES128    
  10.             + DBMS_CRYPTO.CHAIN_CBC    
  11.             + DBMS_CRYPTO.PAD_PKCS5;    
  12.    l_enc        RAW (2000);    
  13. BEGIN    
  14.    l_user_psw :=    
  15.       DBMS_CRYPTO.encrypt (UTL_I18N.string_to_raw (l_user_psw, 'AR8MSWIN1256'),    
  16.                            l_mod,    
  17.                            UTL_I18N.string_to_raw (l_key, 'AR8MSWIN1256'));    
  18.        
  19.       DBMS_OUTPUT.put_line ('Encrypted=' || l_user_psw);    
  20.     
  21.    INSERT INTO test VALUES (l_user_id, l_user_psw);    
  22. dbms_output.put_line('done');    
  23.    COMMIT;    
  24. END;
the result is
  1. 132BEDB1C2CDD8F23B5A619412C27B60 
now I want to make identical Aes in c# I know I can call stored procedure from c# and get the same result but I want to make it using c# for security reasons I have tried many ways but ended up with different result! I need help please!

Answers (1)