User Tools

Site Tools


built_in:crypt

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

built_in:crypt [2015/10/03 17:07]
stevegarman [Password check]
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                          ^ Description  ^ 
-| Crypt.Decrypt( text,password )  |              | 
-| Crypt.Encrypt( text,password )  |              | 
-| 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's hash is compared against the saved version. 
- 
-If it does not match, the app does not continue. 
-<code JavaScript md5.js> 
-//Called when application is started. 
-function OnStart() 
-{ 
-    var chk = app.LoadText("hash","unset"); 
-    var pass = prompt("Please enter password",""); 
-    if (pass==null) app.Exit(); 
-    var crypt = app.CreateCrypt(); 
-    var md5 = crypt.Hash( pass, "MD5" ); 
-    md5 = md5.substr(0,22); 
-    if (chk == "unset") app.SaveText("hash", md5) 
-    else if(chk != md5) 
-    { 
-        app.ShowPopup("Incorrect password"); 
-        app.Exit(); 
-    } 
-  
-    //Create a layout with objects vertically centered. 
-    lay = app.CreateLayout( "linear", "VCenter,FillXY" );     
-  
-    //Create a text label and add it to layout. 
-    txt = app.CreateText( "Welcome" ); 
-    txt.SetTextSize( 32 ); 
-    lay.AddChild( txt ); 
-     
-    //Add layout to app.     
-    app.AddLayout( lay ); 
-} 
-</code> 
built_in/crypt.txt · Last modified: 2017/07/01 14:27 (external edit)