des加密问题
我想使用des加密,网上找到这段代码想试试:
imports system.web.security
imports system.security
imports system.security.cryptography
imports system.text
Public Shared Function encrypt(ByVal ptoencrypt As String, ByVal skey As String) As String
Dim des As New descryptoserviceprovider()
Dim inputbytearray() As Byte
inputbytearray = encoding.default.getbytes(ptoencrypt)
'建立加密对象的密钥和偏移量()
'原文使用asciiencoding.ascii方法的getbytes方法()
'使得输入密码必须输入英文文本()
des.key = asciiencoding.ascii.getbytes(skey)
des.iv = asciiencoding.ascii.getbytes(skey)
' 写二进制数组到加密流()
'(把内存流中的内容全部写入)
Dim ms As New system.io.memorystream()
Dim cs As New cryptostream(ms, des.createencryptor, cryptostreammode.write)
'写二进制数组到加密流()
'(把内存流中的内容全部写入)
cs.write(inputbytearray, 0, inputbytearray.length)
cs.flushfinalblock()
'建立输出字符串()
Dim ret As New stringbuilder()
Dim b As Byte
For Each b In ms.toarray()
ret.appendformat("{0:x2}", b)
Next
Return ret.tostring()
End Function
'解密方法
Public Shared Function decrypt(ByVal ptodecrypt As String, ByVal skey As String) As String
Dim des As New descryptoserviceprovider()
'把字符串放入byte数组()
Dim len As Integer
len = ptodecrypt.length / 2 - 1
Dim inputbytearray(len) As Byte
Dim x, i As Integer
For x = 0 To len
i = convert.toint32(ptodecrypt.substring(x * 2, 2), 16)
inputbytearray(x) = CType(i, Byte)
Next
'建立加密对象的密钥和偏移量, 此值重要, 不能修改
des.key = asciiencoding.ascii.getbytes(skey)
des.iv = asciiencoding.ascii.getbytes(skey)
Dim ms As New system.io.memorystream()
Dim cs As New cryptostream(ms, des.createdecryptor, cryptostreammode.write)
cs.write(inputbytearray, 0, inputbytearray.length)
cs.flushfinalblock()
Return encoding.default.getstring(ms.toarray)
End Function
...........................................................................................
但提示以下错误,应该如何解决?
1.未能找到引用的组件"microsoft.office.interop.excel"
2.未能找到引用的组件"VBIDE"
3.无法找到类型库"microsoft.office.core"的包装程序集
4.无法找到类型库"microsoft.office.interop.excel"的包装程序集
5.无法找到类型库"VBIDE"的包装程序集