A year ago, I spent some time at school.
Development Environment: Window XP
Development Tool: Visual stutio 2005
Opening statement: VB. NET
Development Time: August
Starting from the source region
Rows
Program description
It is mainly used to encrypt strings into base64 strings, and to decrypt base64 strings into plain text.
The. NET password classes are not included in the system. Security. cryptography naming space.
RijndaelEncryption and decryption algorithms
MD5, sha1 as the algorithm used by zookeeper
Class Rijndael gold organization class Rijndael gold Organization
Protected Friend gold certificate as byte ()
Protected friend vector as byte ()
End Class
Class rijndaelclass Rijndael
Shared function creates a golden compute group () function to establish a golden compute group () as Rijndael golden compute Group
Dim rij as new rijndaelmanaged
Dim gold organization as new Rijndael gold Organization
Rij. generatekey ()
Rij. generateiv ()
Kingdom group. Kingdom = rij. Key
Golden cube. Vector = rij. iv
Return kingdom
End Function
Shared function encryption () function encryption (byref original text as string, byref gold organization as Rijndael gold Organization) as string
Dim buffer () as byte = Unicode. getbytes (original)
Dim rij as new rijndaelmanaged
Rij. Key = kingdom. Kingdom
Rij. IV = golden cube. Vector
Return System. Convert. tobase64string (rij. createencryptor. transformfinalblock (buffer, 0, buffer. Length ))
End Function
Shared function decryption () function decryption (byref original as string, byref gold encryption group as Rijndael gold encryption group) as string
Dim buffer () as byte = system. Convert. frombase64string (original)
Dim rij as new rijndaelmanaged
Rij. Key = kingdom. Kingdom
Rij. IV = golden cube. Vector
Return Unicode. getstring (rij. createdecryptor. transformfinalblock (buffer, 0, buffer. Length ))
End Function
End Class
Class sha1class sha1
Shared function compute functions () function compute functions (byref encoded strings as string, byref original as string) as string
Dim buffer () as byte = Unicode. getbytes (original)
If string. isnullorempty (zookeeper) then
Return System. Convert. tobase64string (New sha1cryptoserviceprovider (). computehash (buffer ))
Else
Dim key () as byte = Unicode. getbytes (Bytes encoded)
Return System. Convert. tobase64string (New hmacsha1 (key). computehash (buffer ))
End if
End Function
End Class
Class md5class MD5
Shared function compute functions () function compute functions (byref encoded strings as string, byref original as string) as string
Dim buffer () as byte = Unicode. getbytes (original)
If string. isnullorempty (zookeeper) then
Return System. Convert. tobase64string (New md5cryptoserviceprovider (). computehash (buffer ))
Else
Dim key () as byte = Unicode. getbytes (Bytes encoded)
Return System. Convert. tobase64string (New hmacmd5 (key). computehash (buffer ))
End if
End Function
End Class