hashed string

A

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);

}
 
A

Arne Vajhøj

ad said:
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
 
A

Arne Vajhøj

Arne said:
ad said:
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
 
A

ad

Thanks,
If the code is no problem, I intend to use base64, it is shorter.

Arne Vajhøj said:
Arne said:
ad said:
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
 
A

Arne Vajhøj

ad said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top