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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:54:35+00:00 2026-05-26T13:54:35+00:00

I need to translate this into Objective-C, can anyone help ? var randomString =

  • 0

I need to translate this into Objective-C, can anyone help ?

var randomString = "abc";
var computedHash = Convert.ToBase64String(new MD5CryptoServiceProvider().ComputeHash(Encoding.Default.GetBytes(computedValue)));

What is happening here first ?

I thought it was:

  1. get bytes data from the randomString
  2. MD5 that
  3. Convert the result into data
  4. Convert that data into a base 64 string.

This is what I got so far:

NSString    * completeString    = @"abc";
NSData      * bytes             = [completeString dataUsingEncoding:NSUTF8StringEncoding];
NSString    * md5ed             = [bytes md5];
NSData      * data               = [md5ed dataUsingEncoding:NSUnicodeStringEncoding];
NSString    * base64            = [NSString base64StringFromData:data length:[data length]];

I am using a category to generate the MD5 hash.

@implementation NSData (Crypto)

-(NSString*)md5{
    const char *cStr = [self bytes];
    unsigned char digest[CC_MD5_DIGEST_LENGTH];
    CC_MD5( cStr, [self length], digest );
    NSString* s = [NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
                   digest[0], digest[1], 
                   digest[2], digest[3],
                   digest[4], digest[5],
                   digest[6], digest[7],
                   digest[8], digest[9],
                   digest[10], digest[11],
                   digest[12], digest[13],
                   digest[14], digest[15]];
    return s;

}

@end
  • 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-26T13:54:35+00:00Added an answer on May 26, 2026 at 1:54 pm

    I don’t know anything about Objective C, but Encoding.Default.GetBytes() returns the string encoded using UTF-16. And from the name, it seems NSUTF8StringEncoding uses UTF-8.

    So, to get the same results as in C#, you need to get the string encoded as UTF-16.

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

Sidebar

Related Questions

I want to translate this java code into equal objective-c code double[] pMatrix =
Can someone please translate this into English? The primary reference Microsoft.SQLServer.ManagedDTS, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91,
Can someone please translate this high-level code into IA-32 assembly without using any global
We need to have our apps be translated into other languages. This entails renaming
I need to translate the a carbon method into cocoa into and I am
In my COM component I need to translate all errors into the most suitable
I need to translate programs written in a domain specific language into xml representation.
Can anyone help? I have a PHP method that sends an http post: <?php
We have a problem here. We need to translate a website into multiple language.
I need to translate what is commented within the method, to assembler. I have

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.