C# 클래스 Rock.Security.Encryption

From http://stackoverflow.com/questions/202011/encrypt-decrypt-string-in-net
파일 보기 프로젝트 열기: NewSpring/Rock

공개 메소드들

메소드 설명
DecryptString ( string cipherText ) : string

Decrypt the given string. Assumes the string was encrypted using EncryptString(), using an identical sharedSecret.

DecryptString ( string cipherText, string dataEncryptionKey ) : string

Decrypts the string.

EncryptString ( string plainText ) : string

Encrypt the given string using AES. The string can be decrypted using DecryptString(). The sharedSecret parameters must match.

EncryptString ( string plainText, string dataEncryptionKey ) : string

Encrypts the string.

GenerateEncryptionKey ( int length ) : string

Generates the encryption key.

GenerateMachineKey ( int length ) : string

Generates the machine key.

GetSHA1Hash ( string plainText ) : string

Gets the SHA1 hash.

HexToByte ( string hexString ) : byte[]

converts a hexadecimal string to byte.

TryEncryptString ( string plainText, string &cypherText ) : bool

Tries to encrypt the string. Use this in situations where you might just want to skip encryption if it doesn't work. You should use EncryptString in most cases.

비공개 메소드들

메소드 설명
GetDataEncryptionKey ( ) : string

Gets the data encryption key.

ReadByteArray ( Stream s ) : byte[]

Reads the byte array.

메소드 상세

DecryptString() 공개 정적인 메소드

Decrypt the given string. Assumes the string was encrypted using EncryptString(), using an identical sharedSecret.
public static DecryptString ( string cipherText ) : string
cipherText string The text to decrypt.
리턴 string

DecryptString() 공개 정적인 메소드

Decrypts the string.
DataEncryptionKey must be specified in configuration file
public static DecryptString ( string cipherText, string dataEncryptionKey ) : string
cipherText string The cipher text.
dataEncryptionKey string The data encryption key.
리턴 string

EncryptString() 공개 정적인 메소드

Encrypt the given string using AES. The string can be decrypted using DecryptString(). The sharedSecret parameters must match.
public static EncryptString ( string plainText ) : string
plainText string The text to encrypt.
리턴 string

EncryptString() 공개 정적인 메소드

Encrypts the string.
DataEncryptionKey must be specified in configuration file
public static EncryptString ( string plainText, string dataEncryptionKey ) : string
plainText string The plain text.
dataEncryptionKey string The data encryption key.
리턴 string

GenerateEncryptionKey() 공개 정적인 메소드

Generates the encryption key.
public static GenerateEncryptionKey ( int length ) : string
length int The length.
리턴 string

GenerateMachineKey() 공개 정적인 메소드

Generates the machine key.
public static GenerateMachineKey ( int length ) : string
length int The length.
리턴 string

GetSHA1Hash() 공개 정적인 메소드

Gets the SHA1 hash.
Account encoding requires a 'PasswordKey' app setting
public static GetSHA1Hash ( string plainText ) : string
plainText string The plain text.
리턴 string

HexToByte() 공개 정적인 메소드

converts a hexadecimal string to byte.
public static HexToByte ( string hexString ) : byte[]
hexString string The hexadecimal string.
리턴 byte[]

TryEncryptString() 공개 정적인 메소드

Tries to encrypt the string. Use this in situations where you might just want to skip encryption if it doesn't work. You should use EncryptString in most cases.
public static TryEncryptString ( string plainText, string &cypherText ) : bool
plainText string The plain text.
cypherText string The cypher text.
리턴 bool