B4A Library Protect app with code

This library protects app with pin. It uses a protected kvs (pinLockerLP.dat) file to store the pin. User can enable or disable pin.

You can also set the size of the pin and change all labels, msgs, tost messages etc. according to your language.

screen1.png
screen2.png


pinLockerLP
Author: Leon Prokopis
Version: 1.10
  • pinLockerLP
    • Public Fields:
      • Public MAXPASSLENGHT As Int = 4
      • Public textDlgTitle As String = "Secure Application"
      • Public textBtnOK As String = "Ok"
      • Public textBtnNo As String = ""
      • Public textBtnCancel As String = "Cancel"
      • Public textLabelEnablePin As String = "Enable Pin"
      • Public textHintPin1 As String = "Pin"
      • Public textHintPin2 As String = "Retype Pin"
      • Public textToastMsgSuccessSavePin As String = "Pin saved"
      • Public textToastMsgPinDisaled As String = "Pin disabled"
      • Public textLabelEnablePin As String = "Pin enabled"
      • Public textHintEnterPin As String = "Enter Pin"
      • Public textToastWrongPin As String = "Wrong Pin entered"
    • Functions:
      • createPin
        Call the Pin creation dialog. Also in this dialog you can enable or disable pin
      • dlgAskPin
        Ask pin from user
      • isPinActive As Boolean
        Returns True if pin enabled or else returns False
      • Initialize
        Initializes lib
Changelog

  • 1.00
    • Release
  • 1.10
    • Repair a small bug of unitialized value
    • Smaller font size when asking pin
Dont forget to set KVS_ENCRYPTION to build Configuration
screen3.png


Feel free to decompress lib and use it as u like. Feedback always welcome.

Example:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private locker As PinLockerLP
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    locker.Initialize(Root)
    locker.MAXPASSLENGHT = 4
 
    Root.LoadLayout("MainPage")
End Sub


Private Sub Button1_Click
    locker.createPin
End Sub

Private Sub Button2_Click
    If locker.IsPinActive Then
        locker.dlgAskPin
    End If
End Sub
 

Attachments

  • example.zip
    14.1 KB · Views: 367
  • pinLockerLP.b4xlib
    5.2 KB · Views: 301
Last edited:
Top