6

I have an email and want to pull the corresponding image from gravatar.com

With ruby, it's easy:

    require 'Digest/md5'

    Digest::MD5.hexdigest("my string")

Since there is no require method in RubyMotion, how do I generate the hash from the email?

silasjmatson
  • 1,814
  • 18
  • 37

1 Answers1

8

One possibility is using the "NSData+MD5" cocoapod. Install it by adding this to your Rakefile (make sure you have require 'motion-cocoapods' up top):

app.pods do
  pod 'NSData+MD5Digest'
end

Then you can use it like this:

digest = NSData.MD5HexDigest("my string".dataUsingEncoding(NSUTF8StringEncoding))
Dylan Markow
  • 123,080
  • 26
  • 284
  • 201