Encrypts given String in ASCII format.
Namespace:
DidiSoftAssembly: PGPLib (in PGPLib.dll) Version: 1.6.3.19546
Syntax
| C# |
|---|
public string EncryptString( string stringToEncrypt, KeyStore keyStore, string userId ) |
| Visual Basic (Declaration) |
|---|
Public Function EncryptString ( _ stringToEncrypt As String, _ keyStore As KeyStore, _ userId As String _ ) As String |
| Visual C++ |
|---|
public: String^ EncryptString( String^ stringToEncrypt, KeyStore^ keyStore, String^ userId ) |
Parameters
- stringToEncrypt
- Type: System..::.String
plain text string to be encrypted
- keyStore
- Type: DidiSoft..::.KeyStore
KeyStore holding the enryption key
- userId
- Type: System..::.String
Encryption key owner user Id
Return Value
the encrypted string
Remarks
Compression algorithm used is the one specified through Compression
Symmetric cipher algorithm used is the one specified through Cypher
Symmetric cipher algorithm used is the one specified through Cypher
Examples
using System; using DidiSoft; class EncryptStringWithKeyStore { public void Demo() { string recipientKeyUserId = "support@didisoft.com"; // initialize the key store KeyStore ks = new KeyStore(@"DataFiles\key.store", "changeit"); // if this key store contains a key with the desired recipient userId - encrypt, // otherwise notify that there is no such key if (ks.ContainsKey(recipientKeyUserId)) { PGPLib pgp = new PGPLib(); string plainText = "Hello World"; string encryptedString = pgp.EncryptString(plainText, ks, recipientKeyUserId); } else { Console.WriteLine("No key with user Id:" + recipientKeyUserId + " was found in this key store."); } } }
Imports System Imports DidiSoft Class EncryptStringWithKeyStore Public Sub Demo() Dim recipientKeyUserId As String = "support@didisoft.com" ' initialize the key store Dim ks As New KeyStore("DataFiles\key.store", "changeit") ' if this key store contains a key with the desired recipient userId - encrypt, ' otherwise notify that there is no such key If ks.ContainsKey(recipientKeyUserId) Then Dim pgp As New PGPLib() Dim plainText As String = "Hello World" Dim encryptedString As String = pgp.EncryptString(plainText, ks, recipientKeyUserId) Else Console.WriteLine("No key with user Id:" + recipientKeyUserId + " was found in this key store.") End If End Sub End Class