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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:45:08+00:00 2026-06-02T02:45:08+00:00

Working with a base64 encoding for Azure (http://msdn.microsoft.com/en-us/library/dd135726.aspx) and I dont seem to work

  • 0

Working with a base64 encoding for Azure (http://msdn.microsoft.com/en-us/library/dd135726.aspx) and I dont seem to work out how to get the required string back. I’m able to do this in C# where I do the following.

int blockId = 5000;
var blockIdBytes = BitConverter.GetBytes(blockId);
Console.WriteLine(blockIdBytes);
string blockIdBase64 = Convert.ToBase64String(blockIdBytes);
Console.WriteLine(blockIdBase64);

Which prints out (in LINQPad):

Byte[] (4 items)
| 136         |
| 19          |
| 0           |
| 0           |

iBMAAA==

In Qt/C++ I tried a few aporaches, all of them returning the wrong value.

const int a = 5000;
QByteArray b;

for(int i = 0; i != sizeof(a); ++i) {
  b.append((char)(a&(0xFF << i) >>i));
}

qDebug() << b.toBase64(); // "iIiIiA==" 
qDebug() << QByteArray::number(a).toBase64(); // "NTAwMA=="
qDebug() << QString::number(a).toUtf8().toBase64(); // "NTAwMA=="

How can I get the same result as the C# version?

  • 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-02T02:45:09+00:00Added an answer on June 2, 2026 at 2:45 am

    I ended up doing the following:

    QByteArray temp;
    int blockId = 5000;
    
    for(int i = 0; i != sizeof(blockId); i++) {
      temp.append((char)(blockId >> (i * 8)));
    }
    
    qDebug() << temp.toBase64(); // "iBMAAA==" which is correct
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with base64 encoding. I have successfully encoded images to NSString
I was working with a base64 encoding script, but it is throwing a lot
I am using this encoding/decoding javascript 64bit from here http://www.webtoolkit.info/javascript-base64.html so here is the
I am uploading image to server using base64 its working fine if image is
So i'm working with a web api that returns a base64 string representing a
I have been working on a WCF service which will return a Base64 encoded
I am passing base64 encoded image string to the server side with the HTTP
The main problem here is with search url: http://code.google.com/intl/it/query/#p=appengine&q=query It doesn't contain ? symbol,
I am working in Delphi XE2 I am converting base64 byte array to string
i'm working with web services that returns a base64 string representing a pdf file.

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.