ios - 如何在 RubyMotion 中创建字符串的 md5 散列

标签 ios rubymotion

我有一封邮件,想从gravatar.com拉取对应的图片

使用 ruby​​,这很容易:

    require 'Digest/md5'

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

由于 RubyMotion 中没有 require 方法,我如何从电子邮件中生成哈希值?

最佳答案

一种可能性是使用“NSData+MD5”cocoapod。通过将它添加到你的 Rakefile 来安装它(确保你有 require 'motion-cocoapods' up top):

app.pods do
  pod 'NSData+MD5Digest'
end

然后你可以像这样使用它:

digest = NSData.MD5HexDigest("my string".dataUsingEncoding(NSUTF8StringEncoding))

关于ios - 如何在 RubyMotion 中创建字符串的 md5 散列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12202945/

相关文章:

ios - 以编程方式快速定义 UIButton

iphone - 处理发送推送通知错误的方法

objective-c - 将textView的值赋值给int,IOS

ios - RubyMotion 中的 CVPixelBufferCreate

ios - 你能打开没有url方案的ios应用程序吗

iphone - 在 objective-c 中解析文本文件

ios - Swift/菜单( View )随机导致 "Command failed due to signal: Segmentation fault: 11"

ios - 我怎样才能在 ruby​​ 中实现这个 objC 代码

ios - 如何在 ruby​​motion 中为 UIView 创建拆分背景色

ios - 碰巧不以 fileURLWithPath 文件夹中的资源为目标