473,383 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

hashed string

ad
I used the function below to convert a string to a hashed string.
But I found whaterver string I input, I the output hashed sring always have
a "=" character ending.
Is there any problem about this function.

static string StringUtf8ToSha1Base64(string sOri)
{
Byte[] byteOri = UTF8Encoding.UTF8.GetBytes(sOri);
Byte[] byteHash = new SHA1CryptoServiceProvider().ComputeHash(byteOri);
return Convert.ToBase64String(byteHash);

}
Jun 27 '08 #1
4 1802
ad wrote:
I used the function below to convert a string to a hashed string.
But I found whaterver string I input, I the output hashed sring always have
a "=" character ending.
Is there any problem about this function.

static string StringUtf8ToSha1Base64(string sOri)
{
Byte[] byteOri = UTF8Encoding.UTF8.GetBytes(sOri);
Byte[] byteHash = new SHA1CryptoServiceProvider().ComputeHash(byteOri);
return Convert.ToBase64String(byteHash);

}
No.

Base64 often end with a number of '=' (it depends on the length
of the input string).

Arne
Jun 27 '08 #2
Arne Vajhøj wrote:
ad wrote:
>I used the function below to convert a string to a hashed string.
But I found whaterver string I input, I the output hashed sring always
have a "=" character ending.
Is there any problem about this function.

static string StringUtf8ToSha1Base64(string sOri)
{
Byte[] byteOri = UTF8Encoding.UTF8.GetBytes(sOri);
Byte[] byteHash = new
SHA1CryptoServiceProvider().ComputeHash(byteOri );
return Convert.ToBase64String(byteHash);

}

No.

Base64 often end with a number of '=' (it depends on the length
of the input string).
And if that is not good, then I posted code earlier today
to hexify instead.

Arne
Jun 27 '08 #3
ad
Thanks,
If the code is no problem, I intend to use base64, it is shorter.

"Arne Vajhøj" <ar**@vajhoej.dk>
???????:48***********************@news.sunsite.dk. ..
Arne Vajhøj wrote:
>ad wrote:
>>I used the function below to convert a string to a hashed string.
But I found whaterver string I input, I the output hashed sring always
have a "=" character ending.
Is there any problem about this function.

static string StringUtf8ToSha1Base64(string sOri)
{
Byte[] byteOri = UTF8Encoding.UTF8.GetBytes(sOri);
Byte[] byteHash = new
SHA1CryptoServiceProvider().ComputeHash(byteOri) ;
return Convert.ToBase64String(byteHash);

}

No.

Base64 often end with a number of '=' (it depends on the length
of the input string).

And if that is not good, then I posted code earlier today
to hexify instead.

Arne

Jun 27 '08 #4
ad wrote:
If the code is no problem, I intend to use base64, it is shorter.
That is true.

Hex adds 100% overhead, while Base64 only adds 33% overhead.

Arne
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Krakatioison | last post by:
My sites navigation is like this: http://www.newsbackup.com/index.php?n=000000000040900000 , depending on the variable "n" (which is always a number), it will take me anywhere on the site......
5
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
9
by: John F Dutcher | last post by:
I use code like the following to retrieve fields from a form: recd = recd.append(string.ljust(form.getfirst("lname",' '),15)) recd.append(string.ljust(form.getfirst("fname",' '),15)) etc.,...
9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
1
by: Daniel | last post by:
By using this code I made an array from a hashed array to regain a table content and layout as received from a mysql database... my $sth = $dbh->prepare("SELECT * FROM `Groepen';");...
1
by: Jake | last post by:
I have a deadlock situation, part of the problem looks like this; spid ecid dbid ObjId IndId Type Resource Mode Status ------ ------ ------ ----------- ------ ----...
4
by: Bill Borg | last post by:
Hello, I am using hashpasswordforstoringinconfigfile with md5 to generate a 32-character hashed password. But, since that string is only hex characters and is really only 128 bits (16 bytes),...
3
by: ad | last post by:
I want to hash a givien string to a hashed string. How can I do witth c#?
3
oranoos3000
by: oranoos3000 | last post by:
hi I have a page for registration in my site in this page after validation form I cashed password of user by function md5 and then this hashed password save in database I want to recycled the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.