Component: Data

This component is provided by the Data Card

Component name: data.

Tier 1 Callbacks

  • crc32(data:string):string
    Computes CRC-32 hash of the data. Result is in binary format
  • decode64(data:string):string
    Applies base64 decoding to the data.
  • encode64(data:string):string
    Applies base64 encoding to the data.
  • md5(data:string):string
    Computes MD5 hash of the data. Result is in binary format
  • sha256(data:string):string
    Computes SHA2-256 hash of the data. Result is in binary format.
  • deflate(data:string):string
    Applies deflate compression to the data.
  • inflate(data:string):string
    Applies inflate decompression to the data.
  • getLimit():number
    The maximum size of data that can be passed to other functions of the card.

Tier 2 Callbacks

  • encrypt(data:string, key:string, iv:string):string
    Applies AES encryption to the data using the key and (preferably) random IV.
  • decrypt(data:string, key:string, iv:string):string
    Reverses AES encryption on the data using the key and the IV.
  • random(len:number):string
    Generates a random binary string of len length.

Tier 3 Callbacks

  • generateKeyPair([bitLen:number]):table, table
    Generates a public/private key pair for various cryptiographic functions.
    Optional second parameter specifies key length, 256 or 384 bits accepted.
    Key types include “ec-public” and “ec-private”. Keys can be serialized with
    key.serialize():string Keys also contain the function key.isPublic():boolean
  • ecdsa(data:string, key:userdata[, sig:string]):string or boolean
    Generates a signiture of data using a private key. If signature is present
    verifies the signature using the public key and the previously generated
    generated signature string. and the original string.
  • ecdh(privateKey:userdata, publicKey:userdata):string
    Generates a Diffie-Hellman shared key using the first user's private key and
    the second user's public key. An example of a basic key relation:
    ecdh(userA.private, userB.public) == ecdh(userB.private, userA.public)
  • deserializeKey(data:string, type:string):table
    Transforms a key from string to it's arbitrary type.