C# Class KeePassLib.Security.ProtectedString

Represents an in-memory encrypted string.
Exibir arquivo Open project: cappert/keepass2 Class Usage Examples

Public Methods

Method Description
Insert ( int iStart, string strInsert ) : ProtectedString
ProtectedString ( ) : System

Construct a new protected string object. Protection is disabled.

ProtectedString ( bool bEnableProtection, KeePassLib.Security.XorredBuffer xbProtected ) : System

Construct a new protected string. The string is initialized to the value passed in the XorredBuffer object.

ProtectedString ( bool bEnableProtection, byte vUtf8Value ) : System

Construct a new protected string. The string is initialized to the value supplied in the parameters (UTF-8 encoded string).

ProtectedString ( bool bEnableProtection, string strValue ) : System

Construct a new protected string. The string is initialized to the value supplied in the parameters.

ReadString ( ) : string

Convert the protected string to a normal string object. Be careful with this function, the returned string object isn't protected anymore and stored in plain-text in the process memory.

ReadUtf8 ( ) : byte[]

Read out the string and return a byte array that contains the string encoded using UTF-8. The returned string is not protected anymore!

ReadXorredString ( KeePassLib.Cryptography.CryptoRandomStream crsRandomSource ) : byte[]

Read the protected string and return it protected with a sequence of bytes generated by a random stream.

Remove ( int iStart, int nCount ) : ProtectedString
WithProtection ( bool bProtect ) : ProtectedString

Private Methods

Method Description
Init ( bool bEnableProtection, byte pbUtf8 ) : void
Init ( bool bEnableProtection, string str ) : void

Method Details

Insert() public method

public Insert ( int iStart, string strInsert ) : ProtectedString
iStart int
strInsert string
return ProtectedString

ProtectedString() public method

Construct a new protected string object. Protection is disabled.
public ProtectedString ( ) : System
return System

ProtectedString() public method

Construct a new protected string. The string is initialized to the value passed in the XorredBuffer object.
public ProtectedString ( bool bEnableProtection, KeePassLib.Security.XorredBuffer xbProtected ) : System
bEnableProtection bool Enable protection or not.
xbProtected KeePassLib.Security.XorredBuffer XorredBuffer object containing the /// string in UTF-8 representation. The UTF-8 string must not /// be null-terminated.
return System

ProtectedString() public method

Construct a new protected string. The string is initialized to the value supplied in the parameters (UTF-8 encoded string).
public ProtectedString ( bool bEnableProtection, byte vUtf8Value ) : System
bEnableProtection bool If this parameter is true, /// the string will be protected in memory (encrypted). If it /// is false, the string will be stored as plain-text.
vUtf8Value byte The initial string value, encoded as /// UTF-8 byte array. This parameter won't be modified; the caller /// is responsible for clearing it.
return System

ProtectedString() public method

Construct a new protected string. The string is initialized to the value supplied in the parameters.
public ProtectedString ( bool bEnableProtection, string strValue ) : System
bEnableProtection bool If this parameter is true, /// the string will be protected in memory (encrypted). If it /// is false, the string will be stored as plain-text.
strValue string The initial string value.
return System

ReadString() public method

Convert the protected string to a normal string object. Be careful with this function, the returned string object isn't protected anymore and stored in plain-text in the process memory.
public ReadString ( ) : string
return string

ReadUtf8() public method

Read out the string and return a byte array that contains the string encoded using UTF-8. The returned string is not protected anymore!
public ReadUtf8 ( ) : byte[]
return byte[]

ReadXorredString() public method

Read the protected string and return it protected with a sequence of bytes generated by a random stream.
public ReadXorredString ( KeePassLib.Cryptography.CryptoRandomStream crsRandomSource ) : byte[]
crsRandomSource KeePassLib.Cryptography.CryptoRandomStream Random number source.
return byte[]

Remove() public method

public Remove ( int iStart, int nCount ) : ProtectedString
iStart int
nCount int
return ProtectedString

WithProtection() public method

public WithProtection ( bool bProtect ) : ProtectedString
bProtect bool
return ProtectedString