---
product: Chilkat
product_version: 11.7.0
language: asp
language_label: Classic ASP
class: SecureString
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/asp_SecureStringRef.html
---
# Chilkat SecureString — Classic ASP — v11.7.0

> Chilkat 11.7.0 · language=asp · class=SecureString
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/SecureString.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/guide.md`.

## Purpose

**Store, append, compare, hash, verify, and securely access sensitive string values.**

`Chilkat.SecureString` holds sensitive text in an encrypted in-memory form while still allowing controlled operations on the value. It can append clear-text strings, append text from a `StringBuilder`, append another `SecureString`, load text from a file, return the clear-text value when needed, compare secure strings, mark the value read-only, maintain a hash of the current value, and verify a supplied hash against that maintained value.

**Encrypted in-memory value**

Store sensitive text in a form that is decrypted only when needed for access, modification, comparison, or hashing.

**Append safely**

Append clear-text strings, `StringBuilder` content, or another `SecureString`; the value is then re-encrypted.

**Read-only protection**

Set `ReadOnly` to prevent later modification of the secure string.

**Hash maintenance**

Set `MaintainHash` to a supported hash algorithm such as `sha256`, `sha512`, `sha1`, or `md5`.

**Hash output and verification**

Retrieve the current hash value in an encoding such as hex or Base64, or verify a supplied encoded hash with `VerifyHash`.

**Compare and access**

Compare two secure strings with `SecStrEquals`, or call `Access` when the clear-text value is required.

**Common pattern:** Create a `SecureString`, load or append the sensitive text, set `MaintainHash` if later verification is needed, and optionally set `ReadOnly` after the final value is established. Use `Access` only at the point where the clear-text string is actually needed, and check `LastErrorText` if an append, file load, hash, or verification operation fails.

**Hash note:** `VerifyHash` depends on `MaintainHash` having already been set so the object maintains an internal hash for the current secure string value.

## Object creation, unlocking and error handling

**Object Creation**

```visual-basic
set secureString = Server.CreateObject("Chilkat.SecureString")

' ... use secureString ...

set secureString = Nothing
```

Classic ASP creates Chilkat objects with `Server.CreateObject`. The registered Chilkat ActiveX must match the bitness of the IIS application pool: a pool with *Enable 32-Bit Applications* set to True needs the 32-bit ActiveX, otherwise the 64-bit ActiveX. To bind to a specific major version of Chilkat, append the major version number to the ProgID, such as `Server.CreateObject("Chilkat.SecureString.11")` for Chilkat v11.\*.\*.

VBScript requires `set` when assigning an object, so the signatures on this page show `set x = obj.Method(...)` for methods that return a Chilkat object; test the result with `Is Nothing`, since a method that fails to return an object returns `Nothing`. A method with no return value is called as a statement without parentheses (`obj.Method arg1, arg2`). Boolean properties, arguments and return values are integers in the ActiveX: pass `1` or `0`, and test success with `= 1`. Byte arrays are Variant arrays and can be sent with `Response.BinaryWrite`. Asynchronous (*\*Async*) methods and event callbacks are not used from Classic ASP.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in Classic ASP.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `secureString.DebugLogFilePath ' String` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastBinaryResult` | `secureString.LastBinaryResult ' Variant (read-only)` | read-only | This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. |
| `LastErrorHtml` | `secureString.LastErrorHtml ' String (read-only)` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `secureString.LastErrorText ' String (read-only)` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `secureString.LastErrorXml ' String (read-only)` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `secureString.LastMethodSuccess ' Long` | read/write | Indicates the success or failure of the most recent method call: `1` means success, `0` means failure. |
| `LastStringResult` | `secureString.LastStringResult ' String (read-only)` | read-only | In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. |
| `LastStringResultLen` | `secureString.LastStringResultLen ' Long (read-only)` | read-only | The length, in characters, of the string contained in the LastStringResult property. |
| `VerboseLogging` | `secureString.VerboseLogging ' Long` | read/write | If set to `1`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `secureString.Version ' String (read-only)` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `MaintainHash` | property, read/write | `secureString.MaintainHash ' String` |
| `ReadOnly` | property, read/write | `secureString.ReadOnly ' Long` |
| `Access` | method | `str = secureString.Access() ' String` |
| `Append` | method | `success = secureString.Append(str) ' Long (1/0)` |
| `AppendSb` | method | `success = secureString.AppendSb(sb) ' Long (1/0)` |
| `AppendSecure` | method | `success = secureString.AppendSecure(secStr) ' Long (1/0)` |
| `HashVal` | method | `str = secureString.HashVal(encoding) ' String` |
| `LoadFile` | method | `success = secureString.LoadFile(path, charset) ' Long (1/0)` |
| `SecStrEquals` | method | `success = secureString.SecStrEquals(secStr) ' Long (1/0)` |
| `VerifyHash` | method | `success = secureString.VerifyHash(hashVal, encoding) ' Long (1/0)` |

## Properties

### SecureString.MaintainHash

`Chilkat 11.7.0 · asp · SecureString · MaintainHash · property · read/write · since 9.5.0.71`

```visual-basic
secureString.MaintainHash  ' String
```

If set to the name of a hash algorithm, then a hash of the current string value is maintained. This allows for the hash to be verified via the VerifyHash method. Possible hash algorithm names are `sha1`, `sha256`, `sha384`, `sha512`, `md5`, `md2`, `ripemd160`, `ripemd128`,`ripemd256`, and `ripemd320`.

### SecureString.ReadOnly

`Chilkat 11.7.0 · asp · SecureString · ReadOnly · property · read/write · since 9.5.0.71`

```visual-basic
secureString.ReadOnly  ' Long
```

Can be set to `1` to make this secure string read-only (cannot be modified).

## Methods

### SecureString.Access

`Chilkat 11.7.0 · asp · SecureString · Access · method · since 9.5.0.71`

```visual-basic
str = secureString.Access()  ' String
```

Returns the clear-text string value.

Returns `Nothing` on failure

### SecureString.Append

`Chilkat 11.7.0 · asp · SecureString · Append · method · since 9.5.0.71`

```visual-basic
success = secureString.Append(str)  ' Long (1/0)
```

Appends a clear-text string to this secure string. The in-memory data will be decrypted, the string will be appended, and then it will be re-encrypted. Can return `0` if the string has been marked as read-only via the ReadOnly property.

Returns 1 for success, 0 for failure.

### SecureString.AppendSb

`Chilkat 11.7.0 · asp · SecureString · AppendSb · method · since 9.5.0.71`

```visual-basic
success = secureString.AppendSb(sb)  ' Long (1/0)
```

Appends a clear-text string contained in a StringBuilder to this secure string. The in-memory data will be decrypted, the string will be appended, and then it will be re-encrypted. Can return `0` if the string has been marked as read-only via the ReadOnly property.

Returns 1 for success, 0 for failure.

### SecureString.AppendSecure

`Chilkat 11.7.0 · asp · SecureString · AppendSecure · method · since 9.5.0.71`

```visual-basic
success = secureString.AppendSecure(secStr)  ' Long (1/0)
```

Appends the contents of a secure string to this secure string. The in-memory data will be decrypted, the secure string will be appended, and then it will be re-encrypted. Can return `0` if this string has been marked as read-only via the ReadOnly property.

Returns 1 for success, 0 for failure.

### SecureString.HashVal

`Chilkat 11.7.0 · asp · SecureString · HashVal · method · since 9.5.0.71`

```visual-basic
str = secureString.HashVal(encoding)  ' String
```

Returns the hash value for the current value of this secure string. The `encoding` specifies the encoding to be used. It can be any of the binary encoding algorithms, such as `base64`, `hex`, and many more listed at [Chilkat Binary Encodings](https://www.chilkatsoft.com/binary_encodings.asp)

Returns `Nothing` on failure

### SecureString.LoadFile

`Chilkat 11.7.0 · asp · SecureString · LoadFile · method · since 9.5.0.71`

```visual-basic
success = secureString.LoadFile(path, charset)  ' Long (1/0)
```

Loads the contents of a file into this secure string. The current contents of this object are replaced with the new text from the file.

Returns 1 for success, 0 for failure.

### SecureString.SecStrEquals

`Chilkat 11.7.0 · asp · SecureString · SecStrEquals · method · since 9.5.0.71`

```visual-basic
success = secureString.SecStrEquals(secStr)  ' Long (1/0)
```

Returns `1` if the `secStr` equals the contents of this secure string.

Returns 1 for success, 0 for failure.

### SecureString.VerifyHash

`Chilkat 11.7.0 · asp · SecureString · VerifyHash · method · since 9.5.0.71`

```visual-basic
success = secureString.VerifyHash(hashVal, encoding)  ' Long (1/0)
```

Verifies the `hashVal` against the hash value stored for the current value of this secure string. The MaintainHash property must've previously been set for this secure string to maintain an internal hash. The `encoding` specifies the encoding of the `hashVal`. It can be any of the binary encoding algorithms, such as `base64`, `hex`, and many more listed at [Chilkat Binary Encodings](https://www.chilkatsoft.com/binary_encodings.asp)

Returns 1 for success, 0 for failure.

## Related classes

[`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/classes/StringBuilder.md)

