Home Forums ActiveX components Xceed Encryption for ActiveX Writing public/private/secret keys to text files.

Viewing 1 post (of 1 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #43034 |

    The public/private/secret keys created by the Xceed Encryption Library via the SetSecretKeyFromPassPhrase, SetRandomSecretKey or SetRandomKeyPair methods are not strings. The generated keys (which can be retrieved via the SecretKey, PrivateKey and PublicKey properties) must be encoded (using the Xceed Binary Encoding Library for example) BEFORE they can be written to a text file (as text).

    For example:

    ‘ generate the keys
    rsa.SetRandomKeyPair( 1024, null )

    Dim encoder as XceedBinaryEncoding
    Call encoder.License( “your license key” )

    Dim encodedKey As Variant
    encodedKey = encoder.Encode( rsa.PublicKey, true )

    ‘ Because the encoded key is returned as a variant we need to convert it
    ‘ to a string using the ToString method
    Dim writableKey As String
    writableKey = encoder.ToString( encodedKey )

    ‘ write the writable key to the text file.

    To decode the key, you would need to do the opposite:

    1- Read the writeable key from the text file
    2- Use the FromString method to convert the key back to a variant
    3- Decode the key using the Xceed Binary Encoding’s Decode method
    4- Assign the key to the appropriate property (PublicKey, PrivateKey or SecretKey).

    Imported from legacy forums. Posted by Xceed admin (had 1640 views)

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.