YOUSEFUL / DELPHI / COMPONENTS

EAtlasCryptoError

The one exception class raised by every Atlas Crypto failure: bad arguments, failed authentication, CNG errors and cancel.

Class Unit Atlas.Crypto · Inherits Exception · Product Atlas Crypto

Description

Declared in Atlas.Crypto.Cng as class(Exception) and re-declared in Atlas.Crypto as the same class, so uses Atlas.Crypto is enough to catch it.

Messages fall into four groups:

File-system errors are not wrapped: they arrive as the RTL's EFOpenError, EFCreateError or EOSError.

This type has no members of its own beyond those listed in its description.

Examples

Report why a box did not open

Opens a box with a different key. Prints Decryption failed: wrong key or password, or the data was altered.

pascal
uses System.SysUtils, Atlas.Crypto, Atlas.CryptoBox;

procedure ShowWhyItFailed;
var
  Box: TBytes;
begin
  Box := TAtlasSecretBox.Seal(TAtlasSecretBox.NewKey, TAtlasBytes.OfString('secret'));
  try
    TAtlasSecretBox.Open(TAtlasSecretBox.NewKey, Box);
  except
    on E: EAtlasCryptoError do WriteLn(E.Message);
  end;
end;

TAtlasSecretBox · TAtlasStreamCrypt · TCngAlgorithm

Also in Atlas Crypto

TAtlasHashCalculator · TAtlasFileProtector