A symmetric key may be provided to an application in the "raw" form, i.e. as a sequence of bits, stripped of all version, header and padding information. For example, a 128-bit RC2 key may be provided as a hex string, as follows: "1804A391BBD829605AE7DC3D30B8708B".For AspEncrypt to use such a key for encryption or decryption, the key needs to be imported into a CryptoKey object. However, the methods Context.ImportKeyFromBlob and Context.ImportKeyFromFile only accept symmetric keys in a format generated by AspEncrypt itself, but won't allow a key in the form of a "raw" sequence of bits to be imported.
Starting with Version 2.01 , AspEncrypt is capable of importing "raw" keys via the method ImportRawKey , as follows:Set CM = Server.CreateObject("Persits.CryptoManager")
Set Context = CM.OpenContext("", True)Set Blob = CM.CreateBlob
Blob.Hex = "1804A391BBD829605AE7DC3D30B8708B"
Set Key = Context.ImportRawKey(Blob, calgRC2)
Key.DecryptFile "c:\file.txt.xxx", "c:\file.txt"