| LicenseSpring .Net SDK 8.1.0 Easily add Software Licensing to your application

Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
LicenseSpring.CryptoProviderV2 Class Reference

AES-256-GCM encryption provider using the LSLF binary format. Implements ICryptoProvider so it can be substituted for the legacy CryptoProvider via `Configuration.CryptoProvider`. More...

Inheritance diagram for LicenseSpring.CryptoProviderV2:

## Public Member Functions
| CryptoProviderV2 ()
| CryptoProviderV2 constructor.
| CryptoProviderV2 (IConfiguration config)
| CryptoProviderV2 constructor, initialize object with data from Configuration.
| CryptoProviderV2 (string key, string salt=null)
| CryptoProviderV2 constructor, initialize object with given key and salt.
string | Decrypt (string inputString)
string | Encrypt (string inputString)
byte[] | ExtractSalt (string data)
| Extracts the 16-byte salt from an existing new-format Latin-1-packed string. Returns `null` if the data is not in new format or is too short.
bool | IsNewFormat (byte[] raw)
| Returns `true` if the raw byte array starts with the LSLF magic bytes.
bool | IsNewFormat (string data)
| Returns `true` if the Latin-1-packed input starts with the LSLF magic bytes.

## Properties
string | Key`[get, set]`
| Encryption password (PBKDF2 input).
string | Salt`[get, set]`
| Base64-encoded 16-byte salt to reuse on the next Encrypt(string). Null or empty means "generate a fresh random salt". Ignored by Decrypt(string).
Properties inherited from LicenseSpring.ICryptoProvider

## Detailed Description

AES-256-GCM encryption provider using the LSLF binary format. Implements ICryptoProvider so it can be substituted for the legacy CryptoProvider via `Configuration.CryptoProvider`.

Binary layout of the produced payload (written verbatim to disk — no base64, no text encoding): Offset Size Field 0 4 Magic: 0x4C 0x53 0x4C 0x46 ("LSLF") 4 2 Format version: 0x01 0x00 (uint16 LE) 6 1 Cipher ID: 0x01 (AES-256-GCM) 7 1 KDF ID: 0x01 (PBKDF2-SHA256) 8 4 KDF iteration count: uint32 LE (100000) 12 16 Salt (random, generated once per file) 28 12 IV/nonce (random, regenerated on every write) 40 ... Ciphertext with 16-byte GCM authentication tag appended

AAD = header bytes [0..40).

The ICryptoProvider contract is string-shaped but the returned/accepted string is a transparent byte container packed with ISO-8859-1 (Latin-1). Every byte 0x00..0xFF maps to a single UTF-16 code unit in U+0000..U+00FF, so arbitrary binary bytes round-trip through the string without normalization or surrogate concerns.

The instance Salt property holds the base64-encoded 16-byte salt used as PBKDF2 input on the next Encrypt(string) call. When null or empty, a fresh random salt is generated. Decrypt(string) ignores it — the salt is read from the blob's header.

## Constructor & Destructor Documentation

## ◆ CryptoProviderV2() [1/2]

LicenseSpring.CryptoProviderV2.CryptoProviderV2 | ( | IConfiguration | config | ) |

CryptoProviderV2 constructor, initialize object with data from Configuration.

Parameters

  config | LicenseSpring Configuration

## ◆ CryptoProviderV2() [2/2]

LicenseSpring.CryptoProviderV2.CryptoProviderV2 | ( | string | key,
|  | string | salt = `null`
| ) |  |

CryptoProviderV2 constructor, initialize object with given key and salt.

Parameters

  key | Encryption password (PBKDF2 input).
  salt | Optional base64-encoded 16-byte salt to reuse on the next Encrypt(string) call.

## Member Function Documentation

## ◆ Decrypt()

string LicenseSpring.CryptoProviderV2.Decrypt | ( | string | inputString | ) |

Decrypt given string.

Parameters

  inputString | The encrypted payload previously produced by Encrypt(string), supplied back byte-for-byte.

Returns
  Decrypted string

Exceptions

  System.ArgumentNullException | In case input data is null or empty.
  System.InvalidOperationException | In case the method was called without prior setting the Key property.

Implements LicenseSpring.ICryptoProvider.

## ◆ Encrypt()

string LicenseSpring.CryptoProviderV2.Encrypt | ( | string | inputString | ) |

Encrypt given string.

Parameters

  inputString | String to encrypt

Returns
  The encrypted payload. Depending on the provider this may be an opaque binary byte container rather than printable text; if you persist it, preserve it byte-for-byte (see ILicenseStorage).

Exceptions

  System.InvalidOperationException | In case the method was called without prior setting the Key property.

Implements LicenseSpring.ICryptoProvider.

## Property Documentation

## ◆ Key

string LicenseSpring.CryptoProviderV2.Key
| get set

Encryption password (PBKDF2 input).

Implements LicenseSpring.ICryptoProvider.

## ◆ Salt

string LicenseSpring.CryptoProviderV2.Salt
| get set

Base64-encoded 16-byte salt to reuse on the next Encrypt(string). Null or empty means "generate a fresh random salt". Ignored by Decrypt(string).

Implements LicenseSpring.ICryptoProvider.

The documentation for this class was generated from the following file:

- CryptoProviderV2.cs