J
John Smith
Operating System: PocketPC 2003 (Emulator)
Language: VB.NET
I have downloaded the "Pocket PC Signature Application Sample" from
Microsoft's website
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/
html/PPCSignatureApp.asp) and have gotten it to work successfully. I am
trying to rip-off the Encryption and Decryption capability from the sample
application and put it into another application that contains passwords in
it. My problem is that after I have duplicated (add existing item...) the 6
vb class files into my project and call the "Crypto.Encrypt()" Function
through my test run I receive a MissingMethodException Error. I did not
change the vb class files whatsoever. I didn't do anything more other than
"add existing item..." The build finishes successfully.
Any ideas? Thanx in Advance. (Sample Code Below)
'------------------------------------------------
'Code with Error: (Crypto.vb - Encrypt Function)
'------------------------------------------------
' Encrypt data. Use passphrase to generate the encryption key.
' Returns a byte array that contains the encrypted data.
Public Shared Function Encrypt(ByVal passphrase As String, ByVal data() As
Byte) As Byte()
' holds encrypted data
Dim buffer As Byte() = Nothing
' crypto handles
Dim hProv As IntPtr = IntPtr.Zero
Dim hKey As IntPtr = IntPtr.Zero
Try
' get crypto provider, specify the provider (3rd argument)
' instead of using default to ensure the same provider is
' used on client and server
'***********************************************************************
' This next line generated the error.
'***********************************************************************
If Not WinApi.CryptAcquireContext(hProv, Nothing, WinApi.MS_DEF_PROV, _
WinApi.PROV_RSA_FULL, WinApi.CRYPT_VERIFYCONTEXT) Then
Failed("CryptAcquireContext")
End If
'**** Etc... (Code)
'------------------------------------------------
'Sample Code to call function:
'------------------------------------------------
Private Sub MySubroutine()
' Initialization vector converted to a byte array.
Dim initString() As Byte = Nothing
' Get bytes of initialization vector.
If (txtTitle.Text Is Nothing) Then
initString = New Byte() {}
Else
initString = Encoding.ASCII.GetBytes(txtPassword.Text)
End If
' encrypt the signature data
Dim encryptData As Byte() =
Crypto.Encrypt(Global.Settings.GetString(SettingKeys.CryptPassphrase),
initString)
' update the encrypted view
txtUserName.Text = Encoding.ASCII.GetString(encryptData, 0,
encryptData.Length)
End Sub
Thanx in Advance,
John Smith
Language: VB.NET
I have downloaded the "Pocket PC Signature Application Sample" from
Microsoft's website
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/
html/PPCSignatureApp.asp) and have gotten it to work successfully. I am
trying to rip-off the Encryption and Decryption capability from the sample
application and put it into another application that contains passwords in
it. My problem is that after I have duplicated (add existing item...) the 6
vb class files into my project and call the "Crypto.Encrypt()" Function
through my test run I receive a MissingMethodException Error. I did not
change the vb class files whatsoever. I didn't do anything more other than
"add existing item..." The build finishes successfully.
Any ideas? Thanx in Advance. (Sample Code Below)
'------------------------------------------------
'Code with Error: (Crypto.vb - Encrypt Function)
'------------------------------------------------
' Encrypt data. Use passphrase to generate the encryption key.
' Returns a byte array that contains the encrypted data.
Public Shared Function Encrypt(ByVal passphrase As String, ByVal data() As
Byte) As Byte()
' holds encrypted data
Dim buffer As Byte() = Nothing
' crypto handles
Dim hProv As IntPtr = IntPtr.Zero
Dim hKey As IntPtr = IntPtr.Zero
Try
' get crypto provider, specify the provider (3rd argument)
' instead of using default to ensure the same provider is
' used on client and server
'***********************************************************************
' This next line generated the error.
'***********************************************************************
If Not WinApi.CryptAcquireContext(hProv, Nothing, WinApi.MS_DEF_PROV, _
WinApi.PROV_RSA_FULL, WinApi.CRYPT_VERIFYCONTEXT) Then
Failed("CryptAcquireContext")
End If
'**** Etc... (Code)
'------------------------------------------------
'Sample Code to call function:
'------------------------------------------------
Private Sub MySubroutine()
' Initialization vector converted to a byte array.
Dim initString() As Byte = Nothing
' Get bytes of initialization vector.
If (txtTitle.Text Is Nothing) Then
initString = New Byte() {}
Else
initString = Encoding.ASCII.GetBytes(txtPassword.Text)
End If
' encrypt the signature data
Dim encryptData As Byte() =
Crypto.Encrypt(Global.Settings.GetString(SettingKeys.CryptPassphrase),
initString)
' update the encrypted view
txtUserName.Text = Encoding.ASCII.GetString(encryptData, 0,
encryptData.Length)
End Sub
Thanx in Advance,
John Smith