'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
End Sub
Sub AppStart (Args() As String)
Dim pieKey As String = "u7crun6Qk4g4z0qxJRAWGA=="
Dim nonce As String = "QizYxctgAj5TNxMQPLeaQg=="
Log(CreateHmacSHA1DigestBase64(pieKey, nonce))
End Sub
' Note: All inputs and outputs are Base64 encoded
' Adapted from: https://www.b4x.com/android/forum/threads/help-me-with-twitter-api-1-1.33947/
Sub CreateHmacSHA1DigestBase64(key As String, data As String) As String
Dim su As StringUtils
Dim m As Mac
Dim k As KeyGenerator
k.Initialize("HmacSHA1")
k.KeyFromBytes(su.DecodeBase64(key))
m.Initialise("HmacSHA1", k.Key)
m.Update(su.DecodeBase64(data))
Dim b() As Byte
b = m.Sign
Return(su.EncodeBase64(b))
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub