Corona中文站

强大、易学的跨平台(iOS/Android)开发框架。QQ群1:74390406(满) 群2:221929599

导航

五分钟学会Corona(十七) -
Corona provides routines for calculating common message digests (hashes) and hash-based message authentication codes (HMAC).

The crypto library is an external library pre-installed into Corona apps. To speed up launch time, it is not automatically loaded by default. In order to use this library, you must explicitly load the library to make the library's functions available to your code. To do this, you should use require, i.e. placing local crypto = require("crypto") at the top of your Lua file.

crypto.digest( algorithm, string [, raw] )

This function generates the message digest of the input string and returns it. See Algorithm Constants for valid values for algorithm. The optional raw flag, defaulted to false, is a boolean indicating whether the output should be a direct binary equivalent of the message digest, or formatted as a hexadecimal string (the default).

crypto.hmac( algorithm, string, key [, raw] )

This function computes HMAC of the string and returns it. See Algorithm Constants for valid values for algorithm. The parameter key is used as the seed for the HMAC generation. The optional raw flag, defaulted to false, is a boolean indicating whether the output should be a direct binary equivalent of the HMAC or formatted as a hexadecimal string (the default).

The algorithm parameter is a constant for a hashing algorithm:

• crypto.md4(Note: HMAC is not available for this algorithm)

• crypto.md5

• crypto.sha1

• crypto.sha224

• crypto.sha256

• crypto.sha384

• crypto.sha512
<< 五分钟学会Corona(十六) - Files五分钟学会Corona(十八) - 网络和Web Services >>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最近发表

Powered By Z-Blog 1.8 Walle Build 100427 Copyright 2011-2015 BuildApp.Net. All Rights Reserved.