Skip to content

Corona HTML5 Crypto Plugin similar to standard crypto lib. Includes additional encryption methods.

License

Notifications You must be signed in to change notification settings

develephant/corona-html5-crypto-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Corona HTML5 Crypto Plugin

Corona HTML5 Crypto Plugin similar to standard crypto lib. Includes additional encryption methods.

👷 Built with Corona HTML5 Node Kit.

Install

Add crypto_js.js and crypto.lua to the root of your project.

Require

local crypto = require("crypto")

API

digest

Generates the message digest (the hash) of the input string.

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

Arguments

name description type required
algorithm A constant specifying the hashing algorithm (see Constants). Constant Y
data The input string. String Y
raw Set to true for binary output, or false for hexadecimal string (default). Boolean N

Example

local crypto = require( "crypto" )
local hash = crypto.digest( crypto.md5, "Corona HTML5 Rocks!" )
print( hash )   --> b34ce2675b10580bf9f0d6018c72579c

hmac

Computes HMAC (Key-Hashing for Message Authentication Code) of the string and returns it.

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

Arguments

name description type required
algorithm A constant specifying the hashing algorithm (see Constants). Constant Y
data The input string. String Y
key String to use as the seed for the HMAC generation. String Y
raw Set to true for binary output, or false for hexadecimal string (default). Boolean N

Example

local crypto = require( "crypto" )
local hash = crypto.hmac( crypto.md5, "Corona HTML5 Rocks!", "SomeKey" )
print( hash )   --> 1341b82ca266c77f77b27a318508a481

Encryption

encrypt

Encrypts a string value using a passphrase. Defaults to AES cipher.

crypto.encrypt( data, passphrase [, cipher] )

Arguments

name description type required
data The input data to encrypt. String Y
passphrase The passphrase string. String Y
cipher A constant specifying the cipher to use. Defaults to AES. (see Constants). Constant N

Example

local crypto = require( "crypto" )
local encrypted = crypto.encrypt( "Corona HTML5 Rocks!", "passphrase" )
print( encrypted )   --> U2FsdGVkX19YaYWtxaJQJZ9LYoIFsCJS7pLF5vjHs+Q9v0c8evHoGWJ1dbYsUOKG

decrypt

Decrypts an encrypted value using a passphrase. Defaults to AES cipher.

crypto.decrypt( data, passphrase [, cipher] )

Arguments

name description type required
data The input data to decrypt. String Y
passphrase The passphrase string. String Y
cipher A constant specifying the cipher to use. Defaults to AES. (see Constants). Constant N

Example

local crypto = require( "crypto" )
local decrypted = crypto.decrypt( "U2FsdGVkX19YaYWtxaJQJZ9LYoIFsCJS7pLF5vjHs+Q9v0c8evHoGWJ1dbYsUOKG", "passphrase" )
print( decrypted )   --> Corona HTML5 Rocks!

Constants

Digests/HMAC

  • crypto.md5
  • crypto.sha1
  • crypto.sha224
  • crypto.sha256
  • crypto.sha384
  • crypto.sha512

Does not support md4.

Encrypt/Decrypt

  • crypto.aes (default)
  • crypto.des (triple DES)
  • crypto.rabbit

©2018 C. Byerley (develephant)

About

Corona HTML5 Crypto Plugin similar to standard crypto lib. Includes additional encryption methods.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages