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 8935551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:00:48+00:00 2026-06-15T10:00:48+00:00

I have a checksum that I need to add to a ruby string in

  • 0

I have a checksum that I need to add to a ruby string in hex. I have been unable to convert the checksum successfully. I am relatively new to ruby, so I’m not sure if I’m missing something. Here is what I am doing:

  def get_checksum message
    # get the checksum
    cnt = 0
    lrc = 0
    while (cnt < message.length - 1)
      lrc = lrc ^ message[cnt].to_i
      cnt += 1
    end

    # return as hex
    lrc.to_s.each_byte.map { |b| b.to_s(16) + " " }.join
  end

I have some c# reference code as well, but have never used C# being a long time mac C/C++/Obj-C coder. Here is the C# code I am trying to convert:

// calculate LRC
private string GetChecksum(string inputstring)
{
    int checksum = 0;
    foreach (char c in inputstring)
    {
        checksum ^= Convert.ToByte(c);
    }
    return checksum.ToString("X2");
}

Any help would be appreciated.

  • 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-15T10:00:50+00:00Added an answer on June 15, 2026 at 10:00 am

    .to_i will return 0 when called on a character.

    def get_checksum message
       # get the checksum
       lrc = 0
       message.each_byte do |b|
          lrc = lrc ^ b
       end
       # return as hex
       lrc.to_s(16)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string 0AAE0000463130004144430000 and I need to calculate the two's complement checksum
I need to compute ICMPv6 checksum. I have found correct manual in RFC 2460
I need a small program that can calculate the checksum from a user input.
We need to write software that would continuously (i.e. new data is sent as
Need a clarification while looking at calculating a running checksum. Assume I have data
I need the checksum of an XML file in order to verify that no
I want to auto-generate a unique 8-10 character ID string that includes a checksum
I need a little utility function that generates a checksum from an array of
I have a web service that is outward-facing, however I need to generate a
I need to add a form to my existing application i have it all

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.