-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb4aaescrypto.b4a
67 lines (59 loc) · 2.17 KB
/
b4aaescrypto.b4a
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
Version=7.3
NumberOfModules=1
Module1=Starter
Build1=Default,b4a.example.cry
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~'End of default text.~\n~
IconFile=
NumberOfFiles=0
NumberOfLibraries=2
Library1=core
Library2=cry
@EndOfDesignText@
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Dim a As crypto
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim PASSWORD_BASED As Boolean : PASSWORD_BASED = False
Dim EXAMPLE_PASSWORD As String : EXAMPLE_PASSWORD = "Correct password"
Dim textToEncrpt As String : textToEncrpt = "B4A Aes"
Dim KEY As Object
If(PASSWORD_BASED) Then
'generate salt as string
Dim salt As String : salt = a.saltString(a.generateSalt())
KEY = a.generateKeyFromPassword(EXAMPLE_PASSWORD, salt.GetBytes("UTF8"))
Else
Log("False Random Key Generated")
KEY = a.generateKey
End If
'Encryption section
Log(a.encrypt(textToEncrpt, KEY))
'store encryption
Dim Encryption As Object = a.encrypt(textToEncrpt, KEY)
Log("store" & Encryption)
'Decryption
Try
Dim Decryption As Object = a.decryptString(Encryption, KEY, "UTF-8")
Log(Decryption)
Log("Do they equal: " & textToEncrpt.EqualsIgnoreCase(Decryption))
Catch
Log("bad password")
End Try
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub