TizzyT

EZRSA -TizzyT

Apr 1st, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.79 KB | None | 0 0
  1. 'Reminder for RSA .net
  2. Public Class EZRSA
  3.     Public RSACSP As RSACryptoServiceProvider
  4.     Public RSAinfo As RSAParameters
  5.     Private Padding As Boolean
  6.     Sub New(ByVal KeySize As Integer, Optional ByVal Padding As Boolean = True)
  7.         If KeySize < 384 Then Throw New Exception("KeySize must be 384 or higher")
  8.         If KeySize Mod 8 > 0 Then Throw New Exception("KeySize must be a multiple of 8")
  9.         RSACSP = New RSACryptoServiceProvider(KeySize)
  10.         RSAinfo = RSACSP.ExportParameters(True)
  11.         Me.Padding = Padding
  12.     End Sub
  13.     Function Encrypt(ByVal Data() As Byte) As Byte()
  14.         Return RSACSP.Encrypt(Data, Padding)
  15.     End Function
  16.     Function Decrypt(ByVal Data() As Byte) As Byte()
  17.         Return RSACSP.Decrypt(Data, Padding)
  18.     End Function
  19. End Class
Advertisement
Add Comment
Please, Sign In to add comment