重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
我的key和iv都是指向cpu和主板序号,只能找个修改一下给你,key和iv可以是0-255的任意数值,用连续的编号的方式是便于数码芹袜首和位数,md5部分自己写吧
成都创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站建设、做网站、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的北辰网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
'vb点虐 2005
Imports System.Diagnostics
Imports System.Security.Cryptography
Imports System.IO
Public Class Form1
Public My_key() As Byte = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim aa, bb As String
aa = EncryptTripleDES("今天很冷123456789")
bb = DecryptTripleDES(aa)
End Sub
'TRIPLE DES加密
Private Function EncryptTripleDES(ByVal value As String) As String
Dim des_iv() As Byte = {0, 1, 2, 3, 4, 5, 6, 7}
Dim cryptoProvider As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider()
Dim ms As MemoryStream = New MemoryStream()
Dim cs As CryptoStream = New CryptoStream(ms, cryptoProvider.CreateEncryptor(My_key, des_iv), CryptoStreamMode.Write)
Dim sw As StreamWriter = New StreamWriter(cs)
'Dim a As Integer
'a = cryptoProvider.KeySize '密钥大小
sw.Write(value)
sw.Flush()
cs.FlushFinalBlock()
ms.Flush()
Return Convert.ToBase64String(ms.GetBuffer(), 0, ms.Length)
End Function
'迟激TRIPLE DES解密
Private Function DecryptTripleDES(ByVal value As String) As String
Dim des_iv() As Byte = {0, 1, 2, 3, 4, 5, 6, 7}
Dim cryptoProvider As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider()
Dim buffer As Byte() = Convert.FromBase64String(value)
Dim ms As MemoryStream = New MemoryStream(buffer)
Dim cs As CryptoStream = New CryptoStream(ms, cryptoProvider.CreateDecryptor(My_key, des_iv), CryptoStreamMode.Read)
Dim sr As StreamReader = New StreamReader(cs)
Return sr.ReadToEnd()
End Function
End Class
首先,还是谈谈图像像素时数据获取方面吧,点虐 中的图像相关类基本上都是基于GDI+的,因此,图像数据的获取其实也是调用GDI+的一些函数。这个函数就是LockBits,在vb点虐 中彩色图像数据的快速获取 一文中,我们是调用了Marshal.Copy把LockBits锁定的内存数据拷贝到数据中,然后对数组中的值进行处理。这样做主要的原因是VB.NET不好直接访问内存(Marshal.ReadByte之类的函数不适合用于大型的循环中)。那么,这就造成了2个不好的事情,第一:在同一时间需要2倍于图像数据量的内存,第二:内存数据拷贝到数据,以及处理后再把数组的数据拷贝会内存中都是会减低速度的。困搭春作为一种改进,我们应该充分利用LockBits的功能。LockBits中的LockMode中有一种模式为ImageLockMode.UserInputBuffer,该模式下需要用户先申请内存,然后在把枝橘图像数据按照相关格式填充如这个内存中。这样,就可以先定义个数组,然后把图像数据填充到这个数组中,就避免了来回拷贝的耗时了,简汪耐单示例代码如下:
Dim BmpData As New BitmapData
Stride = ((Bmp.Width * 3 + 3) And HFFFFFFFC)
Dim PixleValue(Stride * Bmp.Height) As Byte
Dim Hanlde As GCHandle = GCHandle.Alloc(PixleValue, GCHandleType.Pinned)
BmpData.Scan0 = Hanlde.AddrOfPinnedObject()
"我有一个确认无档咐错的程序"
其实它把数据先压缩成16进制bcd值(数据长度为原先一半),处理完后把结果再展开成16进春橘制串(长度加倍,即16个字符)
有dll函数可用(和你的确认无错的程序一样效果):
Private Declare Function icePub_desEncryptionHex Lib "icePubDll.dll" (ByVal strInputHexstring As String,ByVal strOutputHexstring As String,ByVal strKeyHexstring As String) As Integer
Private Declare Function icePub_desDecryptionHex Lib "icePubDll.dll" (ByVal strInputHexstring As String,ByVal strOutputHexstring As String,ByVal strKeyHexstring As String) As Integer
Private Declare Function icePub_3desEncryptionHex Lib "icePubDll.dll" (ByVal strInputHexstring As String,ByVal strOutputHexstring As String,ByVal strDoubleKeyHexstring As String) As Integer
Private Declare Function icePub_3desDecryptionHex Lib "icePubDll.dll" (ByVal strInputHexstring As String,ByVal strOutputHexstring As String,ByVal strDoubleKeyHexstring As String) As Integer
Dim str1 As String
str1 = Space(1024)
a2 = icePub_desEncryptionHex("6060606060606060", str1, "6060606060606060")
MsgBox str1
str1 = Space(1024)
a2 = icePub_desDecryptionHex("6060606060606060", str1, "扒蠢团6060606060606060")
MsgBox str1
str1 = Space(1024)
a2 = icePub_3desEncryptionHex("6060606060606060", str1, "60606060606060606565656565656565")
MsgBox str1
str1 = Space(1024)
a2 = icePub_3desDecryptionHex("6060606060606060", str1, "60606060606060606565656565656565")
MsgBox str1
'icePubDll.dll收邮件即可
'或下载即可
"采用DES算法"这个说法不明确,首先是使用多少位的DES进行加密,通常是128位或192位,其次是,要先把主密钥转化成散列,才能供DES进行加密,转化的方法是什么没有明确,通常是md5,所以有的银行卡说是128位md5 3DS就是指用md5转换主密钥散列,用DES进行加密,但是DES本身是64位(包含校验码),举芦岩2DES是128位,3DES是192位,但正御是没有2DES的叫法,所以128位、192位统称3DES
要完整的md5+3DS实例哗吵,需要100分以上,要不到我的空间中查找相关的文章