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

  • Home
  • SEARCH
  • 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 6798139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:41:39+00:00 2026-05-26T18:41:39+00:00

Assume you have a sha-1 algorithm that accepts text as input instead of a

  • 0

Assume you have a sha-1 algorithm that accepts text as input instead of a byte array.
(For instance there are some Javascript libraries like that).

When you would like to apply sha-1 to a text (let’s say the text is a password), then you first do a utf-8 encoding because the text can contain multi-byte characters. In other words, the corresponding integer value of a character in the text can be larger than an 8-bit byte can hold. Since the sha-1 algorithm works on 8-bit units, it helps to encode the text in utf-8 first.

My question is this:
When you have a non-textual binary data where the value of each byte is between 0 and 255, are you still expected to do utf-8 encoding on the binary data before you pass it to the sha-1 algorithm? I know that when the values are between 0 and 127, utf-8 does not modify the data at all.

However, if the values are between 128 and 255, the UTF-8 modifies such data.

In summary, here is my question: What is SHA-1 of the byte containing the value 255 (all 1’s)?

With UTF-8 encoding:    730cf30d408ecf51aad876f5c491f837f7ddea4c

Without UTF-8 encoding: 85e53271e14006f0265921d02d4d736cdc580b0b

Which one is the right one?

  • 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-05-26T18:41:40+00:00Added an answer on May 26, 2026 at 6:41 pm

    No, don’t UTF-8 encode binary data, it makes no sense. If you want a hash of a piece of binary data, you should SHA-1 exactly that, not some random transformation of that data.

    You shouldn’t UTF-8 encode strings either unless what you want is the SHA-1 of the UTF-8 representation of that string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume I have the following: <input type=text> <div id=listofstuff> <div class=anitem> <span class=item name>Dog</span>
Assume I have an array $arr. It's possible that it has an element with
Assume you have input element: <input id=aaa type=text value=unchanged /> Then launch js script:
Assume I have created a compiled re: x = re.compile('^\d+$') Is there a way
Assume you have some objects which have several fields they can be compared by:
Assume I have an ASP.NET MVC app that's not doing anything too fancy (no
Assume I have 10 Methods and 10 Properties. Is there a way to add
Assume I have a Model class called Bird and a instance of Bird called
Assume you have a class that defines virtual methods with the access specifier public.
Assume I have a regular fixed width file that is sorted on one of

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.