StringExtensionsEncrypt(String, String, Byte, Encoding) Method
Encrypts a text by the
Aes algorithm using the provided
password and a randomly generated
salt.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
public static string Encrypt(
this string text,
string password,
out byte[] salt,
Encoding? encoding = null
)
<ExtensionAttribute>
Public Shared Function Encrypt (
text As String,
password As String,
<OutAttribute> ByRef salt As Byte(),
Optional encoding As Encoding = Nothing
) As String
public:
[ExtensionAttribute]
static String^ Encrypt(
String^ text,
String^ password,
[OutAttribute] array<unsigned char>^% salt,
Encoding^ encoding = nullptr
)
[<ExtensionAttribute>]
static member Encrypt :
text : string *
password : string *
salt : byte[] byref *
?encoding : Encoding
(* Defaults:
let _encoding = defaultArg encoding null
*)
-> string
- text String
- The source plain text to encrypt.
- password String
- Password of encryption.
- salt Byte
- When this method returns, contains the randomly generated salt bytes used to derive the key and initialization vector bytes. This parameter is passed uninitialized.
- encoding Encoding (Optional)
- An optional Encoding to transcode the text before encryption.
If , then the actual UTF-16 encoding will be used, which can be faster and may allocate less memory, but
the result may be longer if text contains ASCII characters only, for example. This parameter is optional.
Default value: .
StringThe encrypted result of
text.In Visual Basic and C#, you can call this method as an instance method on any object of type
String. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).