forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencrypt.lcdoc
More file actions
99 lines (76 loc) · 3.64 KB
/
encrypt.lcdoc
File metadata and controls
99 lines (76 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Name: encrypt
Type: command
Syntax: encrypt <source> using <cipher> with {password|key} <passorkey> [and salt <saltvalue>] [and IV <IVvalue>] [at <bitvalue> bit]
Summary:
Encrypt data using a cipher.
Introduced: 2.5
OS: mac, windows, linux, ios, android
Platforms: desktop, server, mobile
Security: network
Example:
-- the following copies a file from disk, stores it in a variable (myData), encrypts the result,
-- then copies the file back to disk.
local path2input, myData, path2output
-- put the file path to your input and output files into path2input and path2output
put URL ("binfile:" & path2input) into myData
encrypt myData using "aes-256-cbc" with password "@&^2fy"
put it into URL ("binfile:" & path2output)
Parameters:
source:
the source input data
cipher:
the format used to encrypt the data
passorkey:
a password or key provided to the encryption routine, as necessary
saltvalue:
the password may also be accompanied by a salt value
IVvalue:
An IV (initialization vector) value may be specified for some cipher
methods
bitvalue:
the bit value specifies the key length in bits (ie. 64, 128, 192, 256,
etc)
It:
On success the variable it will contain the encrypted or decrypted
data.
The result:
On failure encrypt/decrypt set the result to the appropriate
ssl error message. To use OpenSSL functionality with LiveCode, make sure
that the openssl shared library is installed, and in a place where
LiveCode can find it. It is pre-installed with OSX. You can download
and build OpenSSL at www.openssl.org and sitribute with your apps.
LiveCode includes a prebuilt openssl dll which is required to use
OpenSSL for windows (libeay32.dll) which needs to be in the application,
current, or system directory. If LiveCode cannot load SSL, it will
return the error in the result "ssl library not found".
Description:
The <encrypt> and <decrypt> commands accept the source data that will be
encrypted or decrypted. The <cipher> is the name of the cipher obtained
using the <ciphernames> function. The <passorkey> specifies the
password or key that will be used for encryption or decryption as
determined by the keyword before it. If you specify key then the key
needs to be the same size (in bits, eight per byte) as the specified
<cipher> key length. The key may optionally be accompanied by the
<IVvalue> used by some ciphers. If you specify password or don't specify
a key mode, then a password, tyically text, will be used. The password
may optionally be accompanied by a <saltvalue>. The <bitvalue> specifies
the key length in bits (for example, 64, 128, 192 or 256) and may be
zero or empty for the default length (that is listed with the
<cipherNames> function). Some ciphers have fixed key lengths and using
an unsupported value will result in an error.
The key and IV value are the fundamental determiner in block ciphers.
The IV value is typically the width (in bits) of the block associated
with the cipher. The default value is zero. Its use is beyond the scope
of this documentation.
The password and salt value are combined and scrambled to form the key
and IV which are used as described above. The key derivation process is
the same as that used in the openSSL utility. A 16-byte salt prefix is
prepended to the encrypted data, based on the salt value. This is used
in decryption. If no salt value is specified for a password, one is
randomly generated. The use of a randomized salt value is a protection
against dictionary attacks.
Some modes of block ciphers will pad data to be a multiple of block
size. The padding method is that used by the openSSL utility and is a
minimum of one byte.
References: decrypt (command), cipherNames (function),
sslcertificates (property)