function

crypt . crypto . sncode

VERSIONlatest Encrypt a value with an algorythm.

CRYPT

NAME

crypt - Encrypts a value with an algorythm.

SYNOPSIS

crypt(key:'12345678',value:"123"[,algo:'blowfish',error:var])

PARAMETERS

key
Encryption key value (has to be at least 16 characters) Encryption value. It can be a string, context, or array algo Encryption algorythm. By default, it is set to "blowfish". It supports cast5, aes, aes192, twofish128, des(not secure) error If you specified an error variable, then this variable will contain errcode and errmsg. If errcode is not 0, then there is an error. This does not trap error with parameters

RETURN

String
Returns the encrypted string.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

res={_{crypt();}}. return Parameter key must be defined

res={_{crypt(key:'abc');}}. return Parameter value must be defined

res={_{crypt(xx:1,key:'abc');}}. return Parameter xx is not valid

res={_{a=crypt(value:"Pierre",key:'1234567890123456',iv:"1234567890123456"); a; }}.
return res=Vyykaa4u9cg=.

res={_{a=crypt(value:"Pierre",key:'1234567890123456',iv:"1234567890123456");
a;
decrypt(value:a,key:"1234567890123456",iv:"1234567890123456")}}.
return res=Vyykaa4u9cg=Pierre.


res={_{a=crypt(value:"Pierre",key:'1234567890123456');
decrypt(value:a,key:"1234567890123456")}}. return res=Pierre.

res={_{a=crypt(value:[1,2,3],key:'1234567890123456');
decrypt(value:a,key:"1234567890123456")}}. return res=\[1,2,3].

res={_{a=crypt(value:{"a":1,"b":"c"},key:'1234567890123456');
decrypt(value:a,key:"1234567890123456")}}. return res=\{"a":1,"b":"c"}.

res={_{a=crypt(value:{"a":1,"b":[1.2,"c"]},key:'1234567890123456');
decrypt(value:a,key:"1234567890123456")}}. return res=\{"a":1,"b":\[1.2,"c"]}.

res={_{a=crypt(value:{"a":1,"b":[1.2,"c"]},key:'1234567890123456',algo:"cast5");
decrypt(value:a,key:"1234567890123456",algo:"cast5")}}.
return res=\{"a":1,"b":\[1.2,"c"]}.

res={_{a=crypt(value:{"a":1,"b":[1.2,"c"]},key:'1234567890123456',algo:"twofish128");
decrypt(value:a,key:"1234567890123456",algo:"twofish128")}}.
return res=\{"a":1,"b":\[1.2,"c"]}.

res={_{
        a=crypt(value:{"a":1,"b":[1.2,"c"]},key:'1234567890123456',algo:"twofish128");
        decrypt(error:e,value:'a',key:"1234567890123456",algo:"twofish128");
        e;
        }}. return res=.*decode.*.

res={_{
        a=crypt(value:{"a":1,"b":[1.2,"c"]},key:'1234567890123456',algo:"twofish128");
        decrypt(value:'a',key:"1234567890123456",algo:"twofish128");
        e;
        }}. return .*decode.*

res={_{a=crypt(value:{"a":1,"b":[1.2,"c"]},key:'1234567890123456',algo:"aes192");
decrypt(value:a,key:"1234567890123456",algo:"aes192")}}. return res=\{"a":1,"b":\[1.2,"c"]}.

res={_{a=crypt(value:{"a":1,"b":[1.2,"c"]},key:'12345678',algo:"des");
decrypt(value:a,key:"12345678",algo:"des")}}. return res=\{"a":1,"b":\[1.2,"c"]}.

res={_{
        a=crypt(error:e,value:{"a":1,"b":[1.2,"c"]},key:'1345678',algo:"des");
        e;
}}. return res=.*Failed setting the key.*.

res={_{a=crypt(value:{"a":1,"b":[1.2,"c"]},key:'1234567890123456',algo:"x3des");
decrypt(value:a,key:"1234567890123456",algo:"3des")}}. return .*This algorithm.*

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>