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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:46:14+00:00 2026-05-23T12:46:14+00:00

I have to calculate SHA-2 hash of an XOR encrypted string. I am using

  • 0

I have to calculate SHA-2 hash of an XOR encrypted string. I am using RSA BSafe library(very similar to OpenSSL). My XOR function looks something like this:

for (int i = 0; i < strlen(combined); i++)
{
    encrypted[i] = (combined[i] ^ authkey[i%strlen(authkey)]);

}

This produces some ‘\0’ chars (NullTerminations) inside the char array. After this I pass this encrypted string to my hmac() function.
Now the problem is that when BSafe HMAC calculates hashes on character arrays it does not expect ‘\0’ characters in between. How do I circumvent this problem? Even if the answer in given w.r.t functions in OpenSSL it would be helpful as both are very similar.

Thanks in advance!

  • 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-23T12:46:14+00:00Added an answer on May 23, 2026 at 12:46 pm

    With OpenSSL, you pass the length explicitly. The data containing NULLs does not matter.

    unsigned char *HMAC(const EVP_MD *evp_md, const void *key,
                  int key_len, const unsigned char *d, int n,
                  unsigned char *md, unsigned int *md_len);
    

    n is the length of your data, which is pointed to by d. Obviously, you must track the length of *d yourself, as strlen will not work. I would be shocked if BSafe doesn’t work the same way.

    Of course, as my comment said, using a one-time pad twice is horribly insecure. You almost certainly shouldn’t be re-implementing crypto primitives; doesn’t BSafe provide stream ciphers?

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

Sidebar

Related Questions

So reading this post: How can I calculate the SHA-256 hash of a string
i have a function to calculate several different values: int ASPfile::get_dimensions(int* Lat, int* Lon,
i have DataBase function that calculate distance by coordinates CREATE OR REPLACE FUNCTION distance(lat1
I wrote some code using the Microsoft CryptoAPI to calculate a SHA-1 and got
I have a problem with SHA-1 performance on Android. In C# I get calculated
I have to calculate the Specular Highlights (phong) of an Image. the normal Vector
I have to calculate the average of each column in a specific nested list
I have requirement, wherein I have to calculate totals for cash and credit cards
I have code to calculate the percentage difference between 2 numbers - (oldNum -
I have two fields which calculate a total, but I have a radio button

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.