[Personal Work] AES and hash gadgets

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.