HOW TO: ?????? ????? ?????? ".NET Visual Basic ?? Visual Basic ????????? ?? Microsoft Office

?????? ????????? ?????? ?????????
???? ???????: 317535 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

?????? ??? ???? ???? ????? ??????? ????? ??? .NET ?? Visual Basic for Applications. ???? ??? ??????? ????? ?????? Visual Basic for Applications ??????? ????? ??? Visual Basic .NET ?????? ??? ??????? ?????. ????? ??????? ????? ????? ??????? ??????? ?? .NET Framework? ???????/?? ???????.

????? ????? ?????? Visual Basic .NET

  1. ??? ????? Microsoft Visual Studio .NET. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????. ??? ???????? Visual Basic ? ??? ????? ??????. ??? ??? CryptoClass ?? ???? ??? ?????. ??? ????? Class1 ???? ???????.
  2. ??????? ??????? Class1 ???????? ???????? ???????:

    Imports System.Security.Cryptography
    
    <ComClass(Class1.ClassId, Class1.InterfaceId, Class1.EventsId)> Public Class Class1
        Public Const ClassId As String = "98349785-8BE2-4604-848D-F5B103D61715"
        Public Const InterfaceId As String = "36613EE9-125F-493d-9968-771E18C2226A"
        Public Const EventsId As String = "A036F02F-F87E-4548-A536-7DD7EA8E62B5"
    
        Const sKey As String = "MyKey"
    
        Public Function EncryptTripleDES(ByVal sIn As String) As String
            Dim DES As New TripleDESCryptoServiceProvider()
            Dim hashMD5 As New MD5CryptoServiceProvider()
    
            ' Compute the MD5 hash.
            DES.Key = hashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(sKey))
            ' Set the cipher mode.
            DES.Mode = CipherMode.ECB
            ' Create the encryptor.
            Dim DESEncrypt As ICryptoTransform = DES.CreateEncryptor()
            ' Get a byte array of the string.
            Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(sIn)
            ' Transform and return the string.
            Return Convert.ToBase64String(DESEncrypt.TransformFinalBlock(Buffer, 0, Buffer.Length))
        End Function
    
        Public Function DecryptTripleDES(ByVal sOut As String) As String
            Dim DES As New TripleDESCryptoServiceProvider()
            Dim hashMD5 As New MD5CryptoServiceProvider()
    
            ' Compute the MD5 hash.
            DES.Key = hashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(sKey))
            ' Set the cipher mode.
            DES.Mode = CipherMode.ECB
            ' Create the decryptor.
            Dim DESDecrypt As ICryptoTransform = DES.CreateDecryptor()
            Dim Buffer As Byte() = Convert.FromBase64String(sOut)
            ' Transform and return the string.
            Return System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypt.TransformFinalBlock(Buffer, 0, Buffer.Length))
        End Function
    End Class
    						

    ?????? ????? ??????? ???? GUID ?????? GUID ???? ClassId ? InterfaceId ? EventsId. ?????? GUID ???? ???? ??? ????? GUID ??? ??????? ?????.
  3. ??? ????? ????? ?? ????? ???????. ???? ??? ????? ?? ?? ?????? ????? COM Interop ???? ????????. ???? ??? ?????.
  4. ?? ??????? ????? ? ???? ??? ????? ???? ?????? DLL.

????? Visual Basic for ????? ??????? ??????? ????? ?????? ?? .NET

  1. ??? ????? Microsoft Excel. ???? ALT + F11 ???? ????? ???? Visual Basic.
  2. ?? ??????? ????? ? ???? ??? ?????? ??????? ????? ???? ????? ?????.
  3. ?? ??????? ????? ? ???? "?????". ????? ???? ??? ????? CryptoClass ?? ???? ??? ?????.
  4. ???? ?? ???? ???????? ???????? ??????? ?? ???? ????????? ???????? ?????? ??????? 1:
    Sub TestCrypto()
      Dim oCrypto As New CryptoClass.Class1
      Dim sCrypt As String
      
      sCrypt = oCrypto.EncryptTripleDES("This is a test")
      MsgBox "Encrypted text = " & sCrypt
      MsgBox "Decrypted text = " & oCrypto.DecryptTripleDES(sCrypt)
    End Sub
    					

?????? ????????? ????????

  1. ?? ??????? ?????? ???? ??? ????? ???????. ?? ??????? ????? ??????? ? ???? ??? TestCrypto ?? ???? ??? ?????.
  2. ??? ??? ???? ????? ????? ????? ??????? ? ???? ??? "?????". ???? ???? ????? ???? ???? ????? ?? ?? ??????.
  3. ??? ????? ????? ????? ????? ??? ??????? ??? ???? ?????? .NET Framework, ???? DLL ??? ?????? ?? ?? ?????? ????? ??????:
    /tlb:CryptoClass.tlb CryptoClass.dll regasm

?????

?????? ??? ??????? ??????? ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ?? Microsoft:
301070HOW TO: ??????? ? ?? ????? ??? ???????? Visual Basic .NET
????? ?? ?????????? ???? ???? ?????? Microsoft Network (MSDN) ?????? ??? ?????:
http://msdn2.microsoft.com/en-us/library/aa188489(office.10).aspx

???????

???? ???????: 317535 - ????? ??? ??????: 10/???? ?????/1428 - ??????: 8.5
????? ???
  • Microsoft Office Access 2003
  • Microsoft Access 2002 Standard Edition
  • Microsoft Office Excel 2003
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Office PowerPoint 2003
  • Microsoft PowerPoint 2002 Standard Edition
  • Microsoft Office Word 2003
  • Microsoft Visual Studio .NET 2003 Professional Edition
  • Microsoft Word 2002 Standard Edition
  • Microsoft Visual Studio .NET 2002 Professional Edition
????? ??????: 
kbmt kbcrypt kbsecurity kbhowtomaster KB317535 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????317535

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com