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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:07:35+00:00 2026-05-23T19:07:35+00:00

I have a piece of code in vb. I need to convert array of

  • 0

I have a piece of code in vb. I need to convert array of bytes to base 64 string. Following is the vb code.

If arrLicence.Count > 0 Then

LicenceBytes = CType(Array.CreateInstance(GetType(Byte),6), Byte())

        LicenceBytes(0) = Convert.ToByte(arrLicence(0).ToString(), 16)
        LicenceBytes(1) = Convert.ToByte(arrLicence(1).ToString(), 16)
        LicenceBytes(2) = Convert.ToByte(arrLicence(2).ToString(), 16) 
        LicenceBytes(3) = Convert.ToByte(arrLicence(3).ToString(), 16) 
        LicenceBytes(4) = Convert.ToByte(arrLicence(4).ToString(), 16)
        LicenceBytes(5) = Convert.ToByte(arrLicence(5).ToString(), 16)

        LicenceString = Convert.ToBase64String(LicenceBytes) '6 byteArray - passed by the user - Base64Encoded

I need its equivalent in iphone. I tried with NSData and base64 conversion but result defers.

I have used this link for conversion.
http://www.cocoadev.com/index.pl?BaseSixtyFour

I tried by creating individual bytes using memcpy and then creating an array but with no success.

What I have tried is as follows:

NSData *d1 =[@"64" dataUsingEncoding:NSUTF16StringEncoding];
NSData *d2 = [@"37" dataUsingEncoding:NSUTF16StringEncoding];
NSData *d3 = [@"81" dataUsingEncoding:NSUTF16StringEncoding];
NSData *d4 = [@"d4" dataUsingEncoding:NSUTF16StringEncoding];

unsigned char *buffer = (unsigned char*)malloc(8);
buffer[0] =  [d1 bytes]  ;
buffer[1] =  [d2 bytes] ;
buffer[2] =  [d3 bytes] ;
buffer[3] =  [d4 bytes] ;

NSData *data = [NSData dataWithBytes:buffer length:4];

NSString *str = [self encodeBase64WithData:data];
free(buffer);

This results in IJCgkA== while code in .NET returns ZDeB1A==

Please note that the conversion is for first four bytes of arrLicence and the input is 64, 37, 81, d4

  • 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-23T19:07:36+00:00Added an answer on May 23, 2026 at 7:07 pm
    //strBusiCode = @"64-37-81-d4-39-6d";
    NSArray *tmp_arr = [strBusiCode componentsSeparatedByString:@"-"];
    NSMutableData *commandToSend= [[NSMutableData alloc] init];
    unsigned char whole_byte;
    char byte_chars[3] = {'\0','\0','\0'};
    int i;
    for (i=0; i < [tmp_arr count]; i++) {
        byte_chars[0] = [[tmp_arr objectAtIndex:i] characterAtIndex:0];
        byte_chars[1] = [[tmp_arr objectAtIndex:i] characterAtIndex:1];
        whole_byte = strtol(byte_chars, NULL, 16);
        [commandToSend appendBytes:&whole_byte length:1]; 
    }
    return commandToSend;
    

    This commandToSend is then converted to base64 data.

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

Sidebar

Related Questions

I have a piece of code where I need to figure out if a
I have this piece of code: <li class=selected><a href=/AmIACandidate.html>Am I a Candidate?</a></li> I need
I have this piece of code #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h>
I have a piece of code like this class Base { public: Base(bool _active)
I have a piece of code that will take a string and repeat it
I have a piece of code where I need to pass the class of
I have the following piece of code, just wanted to check who will call
I have the following piece of code: if (book.type == A) do_something(); else if
I have this piece of code : public class Profile extends Container{ public Profile(String
I have the following piece of code which attempts to determine whether a given

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.