Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:40:08+00:00 2026-06-03T05:40:08+00:00

I want to encrypt some strings based on SHA1 algorithm in both C#.Net and

  • 0

I want to encrypt some strings based on SHA1 algorithm in both C#.Net and Oracle 10g.

My algorithm in C#.Net:

string salt = "123";
System.Security.Cryptography.SHA1 sha = System.Security.Cryptography.SHA1.Create();
byte[] preHash = System.Text.Encoding.UTF32.GetBytes(salt);
byte[] hash = sha.ComputeHash(preHash);

string password = System.Convert.ToBase64String(hash);
password = password.Substring(0, 8);

// password value is: "7yP7/lkJ"

In Oracle:

Create Or Replace Function Sha1(P_Value Varchar2,P_Length Number) Return Varchar2 
Is 
P_String Varchar2(2000) := P_Value ;
L_Hash_Value_Raw    Raw (100);    
Lv_Hash_Value_Varchar   Varchar2 (40); 
Begin   
    L_Hash_Value_Raw := Dbms_Crypto.Hash (Src   => Utl_Raw.Cast_To_Raw(P_String),       
                                         Typ   => Dbms_Crypto.Hash_Sh1);   
-- Convert Into Varchar2 
Select   Utl_Raw.Cast_To_Varchar2(Utl_Encode.Base64_Encode(L_Hash_Value_Raw))
Into   Lv_Hash_Value_Varchar  
From   Dual;  
    Lv_Hash_Value_Varchar := Substr(Lv_Hash_Value_Varchar,0,P_Length);
Return Lv_Hash_Value_Varchar;
End;

Oracle’s invokation:

select SHA1('123', 8) from dual; -- Result: "QLOAFWMI"

Maybe my general question is what is the difference between Oracle (PL/SQL) and .Net regarding encryption/raw/hex levels? I guess that answer would solve this specific problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:40:09+00:00Added an answer on June 3, 2026 at 5:40 am

    you use wrong encoding. try the following code:

    string salt = "123";
    System.Security.Cryptography.SHA1 sha = System.Security.Cryptography.SHA1.Create();
    byte[] preHash = System.Text.Encoding.UTF8.GetBytes(salt);
    byte[] hash = sha.ComputeHash(preHash);
    
    string password = System.Convert.ToBase64String(hash);
    password = password.Substring(0, 8);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am now using Oracle 10g (10.0.2) I want to encrypt some columns in
I use some code to encrypt & decrypt string in C# but i want
I want to encrypt some server data using .NET's RSACryptoServiceProvider and decrypt it when
I want to encrypt some info for a licensing system and I want the
I want to encrypt hash some strings with MD5 in my Mac application. I
so my problem is simple. I want to Encrypt some text and write it
I want to encrypt a string and embed it in a URL, so I
i want to encrypt string in java and decrypt the same string in C#
I have some code to encrypt some strings in Python. Encrypted text is used
we want to encrypt some attributes of our entity, but still be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.