① 求vb md5加解密
代碼很多。仔細看先建一個類Class Mole 取名為ClsAPIMD5復制下面的代碼到類里:'API 做的MD5類Option Explicit
Private Declare Function CryptAcquireContext Lib "advapi32.dll" _
Alias "CryptAcquireContextA" ( _
ByRef phProv As Long, _
ByVal pszContainer As String, _
ByVal pszProvider As String, _
ByVal dwProvType As Long, _
ByVal dwFlags As Long) As LongPrivate Declare Function CryptReleaseContext Lib "advapi32.dll" ( _
ByVal hProv As Long, _
ByVal dwFlags As Long) As LongPrivate Declare Function CryptCreateHash Lib "advapi32.dll" ( _
ByVal hProv As Long, _
ByVal Algid As Long, _
ByVal hKey As Long, _
ByVal dwFlags As Long, _
ByRef phHash As Long) As LongPrivate Declare Function CryptDestroyHash Lib "advapi32.dll" ( _
ByVal hHash As Long) As LongPrivate Declare Function CryptHashData Lib "advapi32.dll" ( _
ByVal hHash As Long, _
pbData As Any, _
ByVal dwDataLen As Long, _
ByVal dwFlags As Long) As LongPrivate Declare Function CryptGetHashParam Lib "advapi32.dll" ( _
ByVal hHash As Long, _
ByVal dwParam As Long, _
pbData As Any, _
pdwDataLen As Long, _
ByVal dwFlags As Long) As LongPrivate Const PROV_RSA_FULL = 1Private Const ALG_CLASS_HASH = 32768Private Const ALG_TYPE_ANY = 0Private Const ALG_SID_MD2 = 1
Private Const ALG_SID_MD4 = 2
Private Const ALG_SID_MD5 = 3
Private Const ALG_SID_SHA1 = 4Enum HashAlgorithm
md2 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD2
MD4 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD4
md5 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD5
SHA1 = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_SHA1
End EnumPrivate Const HP_HASHVAL = 2
Private Const HP_HASHSIZE = 4Function HashString( _
ByVal Str As String, _
Optional ByVal Algorithm As HashAlgorithm = md5) As String
Dim hCtx As Long
Dim hHash As Long
Dim lRes As Long
Dim lLen As Long
Dim lIdx As Long
Dim abData() As Byte ' Get default provider context handle
lRes = CryptAcquireContext(hCtx, vbNullString, _
vbNullString, PROV_RSA_FULL, 0) If lRes <> 0 Then ' Create the hash
lRes = CryptCreateHash(hCtx, Algorithm, 0, 0, hHash) If lRes <> 0 Then ' Hash the string
lRes = CryptHashData(hHash, ByVal Str, Len(Str), 0) If lRes <> 0 Then
' Get the hash lenght
lRes = CryptGetHashParam(hHash, HP_HASHSIZE, lLen, 4, 0) If lRes <> 0 Then ' Initialize the buffer
ReDim abData(0 To lLen - 1) ' Get the hash value
lRes = CryptGetHashParam(hHash, HP_HASHVAL, abData(0), lLen, 0) If lRes <> 0 Then ' Convert value to hex string
For lIdx = 0 To UBound(abData)
HashString = HashString & _
Right$("0" & Hex$(abData(lIdx)), 2)
Next End If End If End If ' Release the hash handle
CryptDestroyHash hHash End If
End If ' Release the provider context
CryptReleaseContext hCtx, 0 ' Raise an error if lRes = 0
If lRes = 0 Then Err.Raise Err.LastDllErrorEnd FunctionFunction HashFile( _
ByVal Filename As String, _
Optional ByVal Algorithm As HashAlgorithm = md5) As String
Dim hCtx As Long
Dim hHash As Long
Dim lFile As Long
Dim lRes As Long
Dim lLen As Long
Dim lIdx As Long
Dim abHash() As Byte ' Check if the file exists (not the best method BTW!)
If Len(Dir$(Filename)) = 0 Then Err.Raise 53
' Get default provider context handle
lRes = CryptAcquireContext(hCtx, vbNullString, _
vbNullString, PROV_RSA_FULL, 0) If lRes = 0 And Err.LastDllError = &H80090016 Then
' There's no default keyset container!!!
' Get the provider context and create
' a default keyset container
lRes = CryptAcquireContext(hCtx, vbNullString, _
vbNullString, PROV_RSA_FULL, CRYPT_NEWKEYSET)
End If
If lRes <> 0 Then ' Create the hash
lRes = CryptCreateHash(hCtx, Algorithm, 0, 0, hHash) If lRes <> 0 Then ' Get a file handle
lFile = FreeFile
' Open the file
Open Filename For Binary As lFile
If Err.Number = 0 Then
Const BLOCK_SIZE As Long = 32 * 1024& ' 32K
ReDim abBlock(1 To BLOCK_SIZE) As Byte
Dim lCount As Long
Dim lBlocks As Long
Dim lLastBlock As Long
' Calculate how many full blocks
' the file contains
lBlocks = LOF(lFile) \ BLOCK_SIZE
' Calculate the remaining data length
lLastBlock = LOF(lFile) - lBlocks * BLOCK_SIZE
' Hash the blocks
For lCount = 1 To lBlocks
Get lFile, , abBlock
' Add the chunk to the hash
lRes = CryptHashData(hHash, abBlock(1), BLOCK_SIZE, 0)
' Stop the loop if CryptHashData fails
If lRes = 0 Then Exit For
Next ' Is there more data?
If lLastBlock > 0 And lRes <> 0 Then
' Get the last block
ReDim abBlock(1 To lLastBlock) As Byte
Get lFile, , abBlock
' Hash the last block
lRes = CryptHashData(hHash, abBlock(1), lLastBlock, 0)
End If
' Close the file
Close lFile
End If If lRes <> 0 Then
' Get the hash lenght
lRes = CryptGetHashParam(hHash, HP_HASHSIZE, lLen, 4, 0) If lRes <> 0 Then ' Initialize the buffer
ReDim abHash(0 To lLen - 1) ' Get the hash value
lRes = CryptGetHashParam(hHash, HP_HASHVAL, abHash(0), lLen, 0) If lRes <> 0 Then ' Convert value to hex string
For lIdx = 0 To UBound(abHash)
HashFile = HashFile & _
Right$("0" & Hex$(abHash(lIdx)), 2)
Next End If End If End If ' Release the hash handle
CryptDestroyHash hHash End If
End If ' Release the provider context
CryptReleaseContext hCtx, 0 ' Raise an error if lRes = 0
If lRes = 0 Then Err.Raise Err.LastDllErrorEnd Function
使用時:Private Sub Form_Load()
Dim mymd5 As New ClsAPIMD5
Dim md5str As String
md5str = mymd5.HashString(" test", md5)
Set mymd5 = Nothing '用完釋放內存End Sub
② 誰知道怎麼給文件加密啊
用這個軟體,非常簡單
文件加密解密系統 V2.2
下載地址
http://www.skycn.com/soft/7060.html
③ powerbuilder 可以調用DES64.dll 對字元串進行加密和解密,但是對加密密碼的長度有限制,最多隻能8位
網上找pb的信息現在不好找了,給你3種加密方法,已發信箱。
都是用過的,能用
④ 簡述入侵檢測常用的四種方法
入侵檢測系統所採用的技術可分為特徵檢測與異常檢測兩種。
1、特徵檢測
特徵檢測(Signature-based detection) 又稱Misuse detection ,這一檢測假設入侵者活動可以用一種模式來表示,系統的目標是檢測主體活動是否符合這些模式。
它可以將已有的入侵方法檢查出來,但對新的入侵方法無能為力。其難點在於如何設計模式既能夠表達「入侵」現象又不會將正常的活動包含進來。
2、異常檢測
異常檢測(Anomaly detection) 的假設是入侵者活動異常於正常主體的活動。根據這一理念建立主體正常活動的「活動簡檔」,將當前主體的活動狀況與「活動簡檔」相比較,當違反其統計規律時,認為該活動可能是「入侵」行為。
異常檢測的難題在於如何建立「活動簡檔」以及如何設計統計演算法,從而不把正常的操作作為「入侵」或忽略真正的「入侵」行為。
(4)pbmd5加密解密方法擴展閱讀
入侵分類:
1、基於主機
一般主要使用操作系統的審計、跟蹤日誌作為數據源,某些也會主動與主機系統進行交互以獲得不存在於系統日誌中的信息以檢測入侵。
這種類型的檢測系統不需要額外的硬體.對網路流量不敏感,效率高,能准確定位入侵並及時進行反應,但是佔用主機資源,依賴於主機的可靠性,所能檢測的攻擊類型受限。不能檢測網路攻擊。
2、基於網路
通過被動地監聽網路上傳輸的原始流量,對獲取的網路數據進行處理,從中提取有用的信息,再通過與已知攻擊特徵相匹配或與正常網路行為原型相比較來識別攻擊事件。
此類檢測系統不依賴操作系統作為檢測資源,可應用於不同的操作系統平台;配置簡單,不需要任何特殊的審計和登錄機制;可檢測協議攻擊、特定環境的攻擊等多種攻擊。
但它只能監視經過本網段的活動,無法得到主機系統的實時狀態,精確度較差。大部分入侵檢測工具都是基於網路的入侵檢測系統。
3、分布式
這種入侵檢測系統一般為分布式結構,由多個部件組成,在關鍵主機上採用主機入侵檢測,在網路關鍵節點上採用網路入侵檢測,同時分析來自主機系統的審計日誌和來自網路的數據流,判斷被保護系統是否受到攻擊。
⑤ java的sha1加密和object-c的sha1加密後的值不一樣,誰能幫我解決一下。多謝了
結果是一樣的, 但是你多搞了一點: java你是用Base64編碼成字元串, 而ObjC你是直接用16進制輸出的, 你java上不Base64編碼, 也輸出成16進制, 就一樣了;