C# Class ServiceStack.RsaUtils

Useful .NET Encryption Utils from: https://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider(v=vs.110).aspx
Show file Open project: ServiceStack/ServiceStack Class Usage Examples

Public Properties

Property Type Description
DefaultKeyPair RsaKeyPair
DoOAEPPadding bool
KeyLength RsaKeyLengths

Public Methods

Method Description
Authenticate ( byte dataToSign, RSAParameters privateKey, string hashAlgorithm = "SHA512", RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
CreatePrivateKeyParams ( RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : RSAParameters
CreatePublicAndPrivateKeyPair ( RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : RsaKeyPair
Decrypt ( byte encryptedBytes, RSAParameters privateKey, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
Decrypt ( byte encryptedBytes, string privateKeyXml, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
Decrypt ( string encryptedText, RSAParameters privateKey, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : string
Decrypt ( string encryptedText, string privateKeyXml, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : string
Decrypt ( this text ) : string
Encrypt ( byte bytes, RSAParameters publicKey, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
Encrypt ( byte bytes, string publicKeyXml, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
Encrypt ( string text, RSAParameters publicKey, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : string
Encrypt ( string text, string publicKeyXml, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : string
Encrypt ( this text ) : string
FromPrivateRSAParameters ( this privateKey ) : string
FromPublicRSAParameters ( this publicKey ) : string
ToPrivateKeyXml ( this privateKey ) : string
ToPrivateRSAParameters ( this privateKeyXml ) : RSAParameters
ToPublicKeyXml ( this publicKey ) : string
ToPublicRSAParameters ( this publicKeyXml ) : RSAParameters
ToPublicRsaParameters ( this privateKey ) : RSAParameters
Verify ( byte dataToVerify, byte signature, RSAParameters publicKey, string hashAlgorithm = "SHA512", RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : bool

Private Methods

Method Description
CreateRsa ( RsaKeyLengths rsaKeyLength ) : RSA

Method Details

Authenticate() public static method

public static Authenticate ( byte dataToSign, RSAParameters privateKey, string hashAlgorithm = "SHA512", RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
dataToSign byte
privateKey RSAParameters
hashAlgorithm string
rsaKeyLength RsaKeyLengths
return byte[]

CreatePrivateKeyParams() public static method

public static CreatePrivateKeyParams ( RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : RSAParameters
rsaKeyLength RsaKeyLengths
return RSAParameters

CreatePublicAndPrivateKeyPair() public static method

public static CreatePublicAndPrivateKeyPair ( RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : RsaKeyPair
rsaKeyLength RsaKeyLengths
return RsaKeyPair

Decrypt() public static method

public static Decrypt ( byte encryptedBytes, RSAParameters privateKey, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
encryptedBytes byte
privateKey RSAParameters
rsaKeyLength RsaKeyLengths
return byte[]

Decrypt() public static method

public static Decrypt ( byte encryptedBytes, string privateKeyXml, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
encryptedBytes byte
privateKeyXml string
rsaKeyLength RsaKeyLengths
return byte[]

Decrypt() public static method

public static Decrypt ( string encryptedText, RSAParameters privateKey, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : string
encryptedText string
privateKey RSAParameters
rsaKeyLength RsaKeyLengths
return string

Decrypt() public static method

public static Decrypt ( string encryptedText, string privateKeyXml, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : string
encryptedText string
privateKeyXml string
rsaKeyLength RsaKeyLengths
return string

Decrypt() public static method

public static Decrypt ( this text ) : string
text this
return string

Encrypt() public static method

public static Encrypt ( byte bytes, RSAParameters publicKey, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
bytes byte
publicKey RSAParameters
rsaKeyLength RsaKeyLengths
return byte[]

Encrypt() public static method

public static Encrypt ( byte bytes, string publicKeyXml, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : byte[]
bytes byte
publicKeyXml string
rsaKeyLength RsaKeyLengths
return byte[]

Encrypt() public static method

public static Encrypt ( string text, RSAParameters publicKey, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : string
text string
publicKey RSAParameters
rsaKeyLength RsaKeyLengths
return string

Encrypt() public static method

public static Encrypt ( string text, string publicKeyXml, RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : string
text string
publicKeyXml string
rsaKeyLength RsaKeyLengths
return string

Encrypt() public static method

public static Encrypt ( this text ) : string
text this
return string

FromPrivateRSAParameters() public static method

public static FromPrivateRSAParameters ( this privateKey ) : string
privateKey this
return string

FromPublicRSAParameters() public static method

public static FromPublicRSAParameters ( this publicKey ) : string
publicKey this
return string

ToPrivateKeyXml() public static method

public static ToPrivateKeyXml ( this privateKey ) : string
privateKey this
return string

ToPrivateRSAParameters() public static method

public static ToPrivateRSAParameters ( this privateKeyXml ) : RSAParameters
privateKeyXml this
return RSAParameters

ToPublicKeyXml() public static method

public static ToPublicKeyXml ( this publicKey ) : string
publicKey this
return string

ToPublicRSAParameters() public static method

public static ToPublicRSAParameters ( this publicKeyXml ) : RSAParameters
publicKeyXml this
return RSAParameters

ToPublicRsaParameters() public static method

public static ToPublicRsaParameters ( this privateKey ) : RSAParameters
privateKey this
return RSAParameters

Verify() public static method

public static Verify ( byte dataToVerify, byte signature, RSAParameters publicKey, string hashAlgorithm = "SHA512", RsaKeyLengths rsaKeyLength = RsaKeyLengths.Bit2048 ) : bool
dataToVerify byte
signature byte
publicKey RSAParameters
hashAlgorithm string
rsaKeyLength RsaKeyLengths
return bool

Property Details

DefaultKeyPair public static property

public static RsaKeyPair,ServiceStack DefaultKeyPair
return RsaKeyPair

DoOAEPPadding public static property

public static bool DoOAEPPadding
return bool

KeyLength public static property

public static RsaKeyLengths KeyLength
return RsaKeyLengths