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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:03:22+00:00 2026-05-11T17:03:22+00:00

I’m using Blowfish.NET newest version,but there is one problem. responce = new byte[6] {

  • 0

I’m using Blowfish.NET newest version,but there is one problem.

responce = new byte[6]
{
     0x00, 0x80 ,0x01, 0x61, 0x00, 0x00
};
byte[] encrypted = new byte[responce.Length];
blowfish.Encrypt(responce, 2, encrypted, 2, input.Length - 2);

I called it the right way,I want it to start read/write from the third byte and the length is 6 – 2,because i dont use two bytes.

The problem:

        public int Encrypt(
        byte[] dataIn,
        int posIn,
        byte[] dataOut,
        int posOut,
        int count) 
    {
        uint[] sbox1 = this.sbox1;
        uint[] sbox2 = this.sbox2;
        uint[] sbox3 = this.sbox3;
        uint[] sbox4 = this.sbox4;

        uint[] pbox = this.pbox;

        uint pbox00 = pbox[ 0];
        uint pbox01 = pbox[ 1];
        uint pbox02 = pbox[ 2];
        uint pbox03 = pbox[ 3];
        uint pbox04 = pbox[ 4];
        uint pbox05 = pbox[ 5];
        uint pbox06 = pbox[ 6];
        uint pbox07 = pbox[ 7];
        uint pbox08 = pbox[ 8];
        uint pbox09 = pbox[ 9];
        uint pbox10 = pbox[10];
        uint pbox11 = pbox[11];
        uint pbox12 = pbox[12];
        uint pbox13 = pbox[13];
        uint pbox14 = pbox[14];
        uint pbox15 = pbox[15];
        uint pbox16 = pbox[16];
        uint pbox17 = pbox[17]; // till this line count is 4

        count &= ~(BLOCK_SIZE - 1); //count becomes 0 after that calc :((

        int end = posIn + count; // 2 + 0 = 2

        while (posIn < end) //no loop :[
        {
            uint hi = (((uint)dataIn[posIn + 3]) << 24) |
                      (((uint)dataIn[posIn + 2]) << 16) |
                      (((uint)dataIn[posIn + 1]) <<  8) |
                              dataIn[posIn    ];

            uint lo = (((uint)dataIn[posIn + 7]) << 24) |
                      (((uint)dataIn[posIn + 6]) << 16) |
                      (((uint)dataIn[posIn + 5]) <<  8) |
                              dataIn[posIn + 4];
            posIn += 8; 

            hi ^= pbox00;
            lo ^= (((sbox1[(int)(hi >> 24)] + sbox2[(int)((hi >> 16) & 0x0ff)]) ^ sbox3[(int)((hi >> 8) & 0x0ff)]) + sbox4[(int)(hi & 0x0ff)]) ^ pbox01;
            hi ^= (((sbox1[(int)(lo >> 24)] + sbox2[(int)((lo >> 16) & 0x0ff)]) ^ sbox3[(int)((lo >> 8) & 0x0ff)]) + sbox4[(int)(lo & 0x0ff)]) ^ pbox02;
            lo ^= (((sbox1[(int)(hi >> 24)] + sbox2[(int)((hi >> 16) & 0x0ff)]) ^ sbox3[(int)((hi >> 8) & 0x0ff)]) + sbox4[(int)(hi & 0x0ff)]) ^ pbox03;
            hi ^= (((sbox1[(int)(lo >> 24)] + sbox2[(int)((lo >> 16) & 0x0ff)]) ^ sbox3[(int)((lo >> 8) & 0x0ff)]) + sbox4[(int)(lo & 0x0ff)]) ^ pbox04;
            lo ^= (((sbox1[(int)(hi >> 24)] + sbox2[(int)((hi >> 16) & 0x0ff)]) ^ sbox3[(int)((hi >> 8) & 0x0ff)]) + sbox4[(int)(hi & 0x0ff)]) ^ pbox05;
            hi ^= (((sbox1[(int)(lo >> 24)] + sbox2[(int)((lo >> 16) & 0x0ff)]) ^ sbox3[(int)((lo >> 8) & 0x0ff)]) + sbox4[(int)(lo & 0x0ff)]) ^ pbox06;
            lo ^= (((sbox1[(int)(hi >> 24)] + sbox2[(int)((hi >> 16) & 0x0ff)]) ^ sbox3[(int)((hi >> 8) & 0x0ff)]) + sbox4[(int)(hi & 0x0ff)]) ^ pbox07;
            hi ^= (((sbox1[(int)(lo >> 24)] + sbox2[(int)((lo >> 16) & 0x0ff)]) ^ sbox3[(int)((lo >> 8) & 0x0ff)]) + sbox4[(int)(lo & 0x0ff)]) ^ pbox08;
            lo ^= (((sbox1[(int)(hi >> 24)] + sbox2[(int)((hi >> 16) & 0x0ff)]) ^ sbox3[(int)((hi >> 8) & 0x0ff)]) + sbox4[(int)(hi & 0x0ff)]) ^ pbox09;
            hi ^= (((sbox1[(int)(lo >> 24)] + sbox2[(int)((lo >> 16) & 0x0ff)]) ^ sbox3[(int)((lo >> 8) & 0x0ff)]) + sbox4[(int)(lo & 0x0ff)]) ^ pbox10;
            lo ^= (((sbox1[(int)(hi >> 24)] + sbox2[(int)((hi >> 16) & 0x0ff)]) ^ sbox3[(int)((hi >> 8) & 0x0ff)]) + sbox4[(int)(hi & 0x0ff)]) ^ pbox11;
            hi ^= (((sbox1[(int)(lo >> 24)] + sbox2[(int)((lo >> 16) & 0x0ff)]) ^ sbox3[(int)((lo >> 8) & 0x0ff)]) + sbox4[(int)(lo & 0x0ff)]) ^ pbox12;
            lo ^= (((sbox1[(int)(hi >> 24)] + sbox2[(int)((hi >> 16) & 0x0ff)]) ^ sbox3[(int)((hi >> 8) & 0x0ff)]) + sbox4[(int)(hi & 0x0ff)]) ^ pbox13;
            hi ^= (((sbox1[(int)(lo >> 24)] + sbox2[(int)((lo >> 16) & 0x0ff)]) ^ sbox3[(int)((lo >> 8) & 0x0ff)]) + sbox4[(int)(lo & 0x0ff)]) ^ pbox14;
            lo ^= (((sbox1[(int)(hi >> 24)] + sbox2[(int)((hi >> 16) & 0x0ff)]) ^ sbox3[(int)((hi >> 8) & 0x0ff)]) + sbox4[(int)(hi & 0x0ff)]) ^ pbox15;
            hi ^= (((sbox1[(int)(lo >> 24)] + sbox2[(int)((lo >> 16) & 0x0ff)]) ^ sbox3[(int)((lo >> 8) & 0x0ff)]) + sbox4[(int)(lo & 0x0ff)]) ^ pbox16;

            lo ^= pbox17;

            dataOut[posOut + 3] = (byte)(lo >> 24);
            dataOut[posOut + 2] = (byte)(lo >> 16);
            dataOut[posOut + 1] = (byte)(lo >>  8);
            dataOut[posOut    ] = (byte) lo;

            dataOut[posOut + 7] = (byte)(hi >> 24);
            dataOut[posOut + 6] = (byte)(hi >> 16);
            dataOut[posOut + 5] = (byte)(hi >>  8);
            dataOut[posOut + 4] = (byte) hi;

            posOut += 8;
        }

        return count;
    }

The blowfish works fine if i pass longer data,but I need to encrypt this one.We’ve found the problem,but my question is:How to fix it?!

  • 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-11T17:03:23+00:00Added an answer on May 11, 2026 at 5:03 pm

    I’m not super familiar with the Blowfish algorithm or, for that matter, the library you’re using. But, in general, I’d say that if you’re having issues with your data not being long enough to encrypt, you could pad it. In other words… If you data isn’t long enough, add a bunch of zeros (or some other character if zeros hold special meaning to you) to the beginning or end of the data before you encrypt it. Then, when you decrypt it, trim the padding characters.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am reading a book about Javascript and jQuery and using one of the
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.