C# 클래스 PerplexMail.Security

This class manages all security related concerns for the PerplexMail package, such as encryption/decryption, hashing and password generation.
파일 보기 프로젝트 열기: PerplexInternetmarketing/PerplexMail-for-Umbraco

Private Properties

프로퍼티 타입 설명
Decrypt string
Encrypt EncryptionResult
Factory Func
Factory Func
GenerateSalt byte[]
HMAC System.Security.Cryptography.HMAC
Hash HashResult
HashWithAuthentication HashResult
SHA System.Security.Cryptography.HashAlgorithm
SlowEquals bool

공개 메소드들

메소드 설명
Decrypt ( EncryptionResult data, string key ) : string

Decrypt ( string secureString ) : string

Ontsleutel een versleutelde string welke is versleuteld met de Encrypt methode.

Encrypt ( string text, string key ) : EncryptionResult

Versleutel een willekeurige string naar een onleesbare variant welke moeilijk is om te kraken. Deze methode dient alleen gebruikt te worden indien de versleutelde tekst ook weer ontsleuteld moet kunnen woren (anders moet je een hash gebruiken).

Encrypt ( string text ) : string

Versleutel een willekeurige string naar een onleesbare variant welke moeilijk is om te kraken. Deze methode dient alleen gebruikt te worden indien de versleutelde tekst ook weer ontsleuteld moet kunnen woren (anders moet je een hash gebruiken).

GeneratePassword ( int length = 12, int minLowerCharCount = 1, int minUpperCharCount = 1, int minDigitCount = 1, int minSpecialCharCount = 1 ) : string

Generate a random password. The "flavour" of the generated password can be altered by changing the password length and minimum character count per type in the method's parameters. Keep in mind that the 'length' parameter may not be smaller then the sum of all the minimum character counts from the other parameters. If the length value exceeds the sum of all the minimum character counts, the miscelanious characters will have be of a random type. If the minimum character count of a type is set to 0, the generated password will not contain any characters of this type.

Hash ( string text, string salt, EnmHashingAlgorithm algorithm = EnmHashingAlgorithm.SHA512 ) : HashResult

Transform any arbitrary input string into a secure and unintelligible hash (string). - Simple and quick - Low level security - NOT to be used for sensitive data such as passwords. Instead use the method method HashPassword.

Not to be used for sensitive data such as passwords

Hash ( string text ) : string

Generate a simple (SHA512) hash from an arbitrary string. NOTE: This method generates a random salt every time the method is called. Calling the method twice will result in two different hash strings. If the Hash is to be used for simple verification purposes, please call the overloaded Hash method.

HashPassword ( string password, EnmSecureHashingAlgorithm algorithm, string salt, string key ) : PasswordResult

HashPassword ( string password ) : string

Genereer een veilige(re) hash voor een string die belangrijke data bevat, zoals een wachtwoord. Deze methode is CPU intensiever dan de methode 'HashString', welke op zijn beurt beter gebruikt kan worden voor snelle en simpele authenticatie hashes.

HashWithAuthentication ( string text, string salt, EnmHashingAlgorithm algorithm, string key ) : HashResult

Transform any arbitrary input string into a secure and unintelligible hash (string). This method is a keyed hashing method which is a lot more secure then the regular hashing methods - The generated keyed hash can be used to verify the authenticity of a message - NOT to be used for securing passwords, instead use the provided method HashPassword.

Not to be used for sensitive data such as passwords

HashWithAuthentication ( string text ) : string

Generates a more secure hash, using a secret key generated from the secret masterkey (specified in the web.config).

ValidateAuthenticationHash ( string verificationText, string hashedText, string key ) : bool

Determines if the contents of the hash string 'hashedText' matches the raw input string 'verificationText'.

ValidateHash ( string originalText, string hashedText ) : bool

Determines if the contents of the hash string 'hashedText' matches the raw input string 'verificationText'.

ValidatePasswordHash ( string password, EnmSecureHashingAlgorithm method, string salt, int iteraties, string passwordHash ) : bool

Valideer of een wachtwoord geldig is door deze met de ingevoerde parameters te vergelijken.

ValidatePasswordHash ( string password, string passwordHash ) : bool

Valideer of een wachtwoord geldig is door deze met de beveiligde hash te vergelijken.

비공개 메소드들

메소드 설명
Decrypt ( byte cipherText, byte salt, byte key ) : string
Encrypt ( byte text, byte key ) : EncryptionResult
Factory ( this enm ) : Func
Factory ( this enm ) : Func
GenerateSalt ( ) : byte[]
HMAC ( this enm ) : HMAC
Hash ( byte text, byte salt, HashAlgorithm algorithm ) : HashResult
HashWithAuthentication ( byte text, byte salt, byte key, EnmHashingAlgorithm algorithm ) : HashResult
SHA ( this enm ) : HashAlgorithm
SlowEquals ( byte a, byte b ) : bool

메소드 상세

Decrypt() 공개 정적인 메소드

public static Decrypt ( EncryptionResult data, string key ) : string
data EncryptionResult
key string
리턴 string

Decrypt() 공개 정적인 메소드

Ontsleutel een versleutelde string welke is versleuteld met de Encrypt methode.
public static Decrypt ( string secureString ) : string
secureString string De volledige secure string zoals deze gegenereerd wordt door Encrypt()
리턴 string

Encrypt() 공개 정적인 메소드

Versleutel een willekeurige string naar een onleesbare variant welke moeilijk is om te kraken. Deze methode dient alleen gebruikt te worden indien de versleutelde tekst ook weer ontsleuteld moet kunnen woren (anders moet je een hash gebruiken).
public static Encrypt ( string text, string key ) : EncryptionResult
text string De tekst welke versleuteld dient te worden
key string De geheime sleutel waarmee de tekst versleuteld dient te worden
리턴 EncryptionResult

Encrypt() 공개 정적인 메소드

Versleutel een willekeurige string naar een onleesbare variant welke moeilijk is om te kraken. Deze methode dient alleen gebruikt te worden indien de versleutelde tekst ook weer ontsleuteld moet kunnen woren (anders moet je een hash gebruiken).
public static Encrypt ( string text ) : string
text string De tekst welke versleuteld dient te worden
리턴 string

GeneratePassword() 공개 정적인 메소드

Generate a random password. The "flavour" of the generated password can be altered by changing the password length and minimum character count per type in the method's parameters. Keep in mind that the 'length' parameter may not be smaller then the sum of all the minimum character counts from the other parameters. If the length value exceeds the sum of all the minimum character counts, the miscelanious characters will have be of a random type. If the minimum character count of a type is set to 0, the generated password will not contain any characters of this type.
public static GeneratePassword ( int length = 12, int minLowerCharCount = 1, int minUpperCharCount = 1, int minDigitCount = 1, int minSpecialCharCount = 1 ) : string
length int The exact length of the password that is to be generated
minLowerCharCount int The minimum number of lowercase characters that should be present in the output
minUpperCharCount int The minimum number of uppsercase characters that should be present in the output
minDigitCount int The minimum number of digits that should be present in the output
minSpecialCharCount int The minimum number of special characters that should be present in the output
리턴 string

Hash() 공개 정적인 메소드

Transform any arbitrary input string into a secure and unintelligible hash (string). - Simple and quick - Low level security - NOT to be used for sensitive data such as passwords. Instead use the method method HashPassword.
Not to be used for sensitive data such as passwords
public static Hash ( string text, string salt, EnmHashingAlgorithm algorithm = EnmHashingAlgorithm.SHA512 ) : HashResult
text string The input string to hash
salt string A string containing 16 or more random characters. The salt should be saved together with the hash. Only use each salt once (read: generate a new salt every time you hash)
algorithm EnmHashingAlgorithm The algorithm that should perform the hashing operation
리턴 HashResult

Hash() 공개 정적인 메소드

Generate a simple (SHA512) hash from an arbitrary string. NOTE: This method generates a random salt every time the method is called. Calling the method twice will result in two different hash strings. If the Hash is to be used for simple verification purposes, please call the overloaded Hash method.
public static Hash ( string text ) : string
text string The text to generate the hash for
리턴 string

HashPassword() 공개 정적인 메소드

public static HashPassword ( string password, EnmSecureHashingAlgorithm algorithm, string salt, string key ) : PasswordResult
password string
algorithm EnmSecureHashingAlgorithm
salt string De te gebruiken salt, welke minimaal uit 16 karakters dient te bestaan
key string De primaire (master) sleutel waarmee de hash gegenereerd dient te worden
리턴 PasswordResult

HashPassword() 공개 정적인 메소드

Genereer een veilige(re) hash voor een string die belangrijke data bevat, zoals een wachtwoord. Deze methode is CPU intensiever dan de methode 'HashString', welke op zijn beurt beter gebruikt kan worden voor snelle en simpele authenticatie hashes.
public static HashPassword ( string password ) : string
password string De veilige string welke gehashed moet worden
리턴 string

HashWithAuthentication() 공개 정적인 메소드

Transform any arbitrary input string into a secure and unintelligible hash (string). This method is a keyed hashing method which is a lot more secure then the regular hashing methods - The generated keyed hash can be used to verify the authenticity of a message - NOT to be used for securing passwords, instead use the provided method HashPassword.
Not to be used for sensitive data such as passwords
public static HashWithAuthentication ( string text, string salt, EnmHashingAlgorithm algorithm, string key ) : HashResult
text string The input string to hash
salt string A string containing 16 or more random characters. The salt should be saved together with the hash. Only use each salt once (read: generate a new salt every time you hash)
algorithm EnmHashingAlgorithm The hashing algorithm to use for the hashing proces
key string The secret key to be used to generate the hash. T
리턴 HashResult

HashWithAuthentication() 공개 정적인 메소드

Generates a more secure hash, using a secret key generated from the secret masterkey (specified in the web.config).
public static HashWithAuthentication ( string text ) : string
text string The input string to hash
리턴 string

ValidateAuthenticationHash() 공개 정적인 메소드

Determines if the contents of the hash string 'hashedText' matches the raw input string 'verificationText'.
public static ValidateAuthenticationHash ( string verificationText, string hashedText, string key ) : bool
verificationText string The raw text to validate
hashedText string The hashed string to validate against
key string The secret key used to generate the hash
리턴 bool

ValidateHash() 공개 정적인 메소드

Determines if the contents of the hash string 'hashedText' matches the raw input string 'verificationText'.
public static ValidateHash ( string originalText, string hashedText ) : bool
originalText string The original text to validate against the hash
hashedText string The complete secure hash string as produced by the other hashing methods
리턴 bool

ValidatePasswordHash() 공개 정적인 메소드

Valideer of een wachtwoord geldig is door deze met de ingevoerde parameters te vergelijken.
public static ValidatePasswordHash ( string password, EnmSecureHashingAlgorithm method, string salt, int iteraties, string passwordHash ) : bool
password string Het plain text wachtwoodr dat vergeleken moet worden met de secure hash
method EnmSecureHashingAlgorithm Het te gebruiken hashing algorithme
salt string Base-64 Encoded salt (gegenereerd met de methode HashPassword)
iteraties int Het aantal hashing iteraties
passwordHash string Base-64 Encoded password hash(Zoals gegenereerd uit de methode HashPassword)
리턴 bool

ValidatePasswordHash() 공개 정적인 메소드

Valideer of een wachtwoord geldig is door deze met de beveiligde hash te vergelijken.
public static ValidatePasswordHash ( string password, string passwordHash ) : bool
password string Het te valideren wachtwoord
passwordHash string De secure string (gegenereerd met de methode HashPassword)
리턴 bool