This shows you the differences between two versions of the page.
built_in:crypt [2015/03/20 14:12] octazid [Table] |
built_in:crypt [2017/07/01 14:27] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Crypt control ====== | ||
- | This control provides methods for encryption and decryption. | ||
- | ===== Methods ===== | ||
- | Some controls use the same methods.\\ | ||
- | For examples of the **[[same methods]]** look here. | ||
- | ^ Method | ||
- | | Crypt.Decrypt( text, | ||
- | | Crypt.Encrypt( text, | ||
- | | Crypt.GetType() | ||
- | | Crypt.Hash( text,mode ) | ||
- | | Crypt.Release() | ||
- | ===== Sample code ===== | ||
- | The code samples available from the IDE include a Security Encryption sample which demonstrates the use of this control. | ||
- | ==== Password check ==== | ||
- | The following code demonstrates the use of an md5 hash to check a password. | ||
- | |||
- | The first time a password is entered, its hash is saved. Every subsequent time, the password' | ||
- | |||
- | If it does not match, the app does not continue. | ||
- | <code JavaScript md5.js> | ||
- | |||
- | // | ||
- | function OnStart() | ||
- | { | ||
- | var crypt = app.CreateCrypt(); | ||
- | var chk = app.LoadText(" | ||
- | var pass = prompt(""," | ||
- | if (pass==null) app.Exit(); | ||
- | var md5 = crypt.Hash( pass, | ||
- | if (chk == " | ||
- | else if(chk != md5) app.Exit(); | ||
- | |||
- | // | ||
- | lay = app.CreateLayout( " | ||
- | |||
- | // | ||
- | txt = app.CreateText( " | ||
- | txt.SetTextSize( 32 ); | ||
- | lay.AddChild( txt ); | ||
- | |||
- | // | ||
- | app.AddLayout( lay ); | ||
- | } | ||
- | </ |