Class Crypt2
- All Implemented Interfaces:
AutoCloseable
Encrypt, decrypt, hash, sign, verify, encode, and authenticate data.
Chilkat.Crypt2 is a broad cryptographic utility class for
applications that need symmetric encryption, decryption, hashing, HMACs,
key derivation, random data generation, one-time passwords, binary encoding,
PKCS#7/CMS signatures, CAdES options, and certificate-based public-key
encryption and decryption. It works with strings, files, byte data,
BinData, and StringBuilder objects, making it useful
for both small in-memory operations and file-based cryptographic workflows.
Encryption and decryption
Encrypt and decrypt strings, files, byte arrays, and Chilkat buffer objects using configurable algorithms, modes, keys, IVs, padding, and encodings.
Hashes and HMACs
Compute message digests and keyed message authentication codes for text, files, byte data, and in-memory buffers.
PKCS#7 / CMS signatures
Create and verify signed data, detached signatures, opaque signatures, and certificate-based signature formats used in many security workflows.
CAdES support
Use CAdES-related options when advanced CMS signature profiles are required for compliance or interoperability.
Key and random utilities
Derive keys, generate random bytes, create one-time passwords, and prepare keying material for cryptographic operations.
Encoding and data conversion
Encode and decode binary data using formats such as Base64, hex, URL encoding, and other supported binary encodings.
Common pattern:
Choose the cryptographic operation, set the algorithm and related options,
provide keys, certificates, passwords, IVs, or encoding settings as needed,
then call the method matching the data form: string, file, bytes,
BinData, or StringBuilder. Check
LastErrorText when diagnosing algorithm, key, certificate,
signature, or encoding issues.
For an extended overview, see Crypt2 Class Overview.
</section>
Event-capable: long-running methods report progress through a ProgressListener installed
with setProgressListener(ProgressListener), onAbortCheck(BooleanSupplier),
onPercentDone(IntPredicate) or onProgressInfo(BiConsumer).
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEncryptCert(Cert cert)Adds a certificate for public-key encryption.voidaddPfxSourceBd(BinData bd, String password)Adds aPFXfile to the object's list of sources for locating certificates and private keys during public-key decryption or signing.voidaddPfxSourceFile(String pfxFilePath, String pfxPassword)Adds aPFXfile to the object's list of sources for locating certificates and private keys during public-key decryption or signing.voidaddSigningCert(Cert cert)Call this method once per certificate to addmultiple certificates for signing.aesKeyUnwrap(String kek, String wrappedKeyData, String encoding)Implements theAES Key Wrap Algorithm(RFC 3394) for unwrapping.aesKeyUnwrapWithPadding(String kek, String wrappedKeyData, String encoding)Implements theAES Key Wrap with Padding Algorithm(RFC 5649) for unwrapping.aesKeyWrap(String kek, String keyData, String encoding)Implements theAES Key Wrap Algorithm(RFC 3394).aesKeyWrapWithPadding(String kek, String keyData, String encoding)Implements theAES Key Wrap with Padding Algorithm(RFC 5649).voidargon2DeriveKey(String password, String json, BinData bdKey)Derives a key from a password using Argon2, the memory-hard key derivation function specified in RFC 9106.argon2HashPassword(String password, String json)Hashes a password using Argon2 (RFC 9106) and returns the result as a PHC format string, such asintargon2VerifyPassword(String password, String json, String phcHash)Verifiespasswordagainst a PHC format Argon2 hash string previously produced by(or by any other RFC 9106 implementation).argon2HashPassword(String, String)bCryptHash(String password)Computes and returns a bcrypt hash of thepassword.voidbCryptVerify(String password, String bcryptHash)Verifies thepasswordagainst a previously computed BCrypt hash.voidckDecryptFile(String srcFile, String destFile)File-to-file decryption that supports files of any size by using internal streaming mode.voidckEncryptFile(String srcFile, String destFile)Encrypts a file to another file using streaming mode, allowing files of virtually any size to be processed without loading the entire file into memory.voidClears the internal list of digital certificates to be used for public-key encryption.voidClears the set of certificates to be used in signing.voidCo-sign's an existing CMS signature.longComputes a CRC for data contained incrcAlg, which can be eithercrc-32used in the Zip file format, orcrc8for the CRC8 algorithm.longCalculates the CRC for a file's contents using the CRC algorithm specified bycrcAlg.voidSigns the contents ofinFilenameand writes the enveloping (i.e.voidSigns the contents ofinFilenameand writes the detachedPKCS7signature (.p7s) top7sPath.decodeString(String inStr, String charset, String encoding)Decodes from an encoding back to the original string.voidDecrypts the contents ofbd.decryptEncoded(String encodedEncryptedData)Decrypts encoded encrypted data, and returns the decrypted data as a binary encoded string.voiddecryptSb(BinData bdIn, StringBuilder sbOut)This function is intended for use when the expected decrypted output is text.voiddecryptSecureENC(String cipherText, SecureString secureStr)This function is intended for use when the expected decrypted output is text.decryptStringENC(String str)This function is intended for use when the expected decrypted output is text.Encodes an integer to N bytes and returns in the specified encoding.encodeString(String strToEncode, String charsetName, String toEncodingName)Binary encodes a string.voidEncrypts the contents ofbd.encryptEncoded(String str)Encrypts binary-encoded data and returns it as a binary-encoded string.voidencryptSb(StringBuilder sbIn, BinData bdOut)Encrypts text and appends the encrypted bytes inbdOut.encryptSecureENC(SecureString secureStr)Encrypts the secure string and returns the encrypted bytes as a binary encoded string.encryptStringENC(String str)Encrypts thestrand returns the encrypted bytes as a binary encoded string.Generates a random UUID string having standard UUID format, such asde305d54-75b4-431b-adb2-eb6b9e546014.genRandomBytesENC(int numBytes)GeneratesnumBytesrandom bytes and returns them as an encoded string.booleanSetting this property totruewill abort the current method, but only for those methods having anAsyncalternative.intThe BCrypt work factor determines the computational cost ofandbCryptHash(String).bCryptVerify(String, String)intThis property indicates the block size in bytes for the chosen encryption algorithm.booleanThis property applies to allPKCS7signature creation methods.This property is for PKCS7 CMS signatures that wish to include CAdESsignature policy attributes.This property is for PKCS7 CMS signatures that wish to include CAdESsignature policy attributes.This property is for PKCS7 CMS signatures that wish to include CAdESsignature policy attributes.This property specifies the character encoding used to represent text as bytes for encryption and hashing.Sets thecipher modefor block encryption algorithms (AES, Blowfish,TwoFish, DES, 3DES, RC2).A JSON string to manage additional CMS (PKCS7) signature and validation options.Selects the encryption algorithm for encrypting and decrypting.getEncodedAuthTag(String encoding)When encrypting inGCMmode, Chilkat generates theGCM authentication tag.getEncodedIV(String encoding)This method retrieves the IV set by the application during the last call toorsetEncodedIV(String, String).randomizeIV()The EncodingMode property specifies thebinary encodingformat (e.g.,base64,hex,base58,base64url) used by functions ending in"ENC", likeandencryptStringENC(String).decryptStringENC(String)booleanUsing theFirstChunkandproperties is the way to do streaming encryption or decryption with Chilkat.getLastChunk()Selects the hash algorithm used by methods that create hashes.intApplies to the HAVAL hash algorithm only and must be set to the integer value 3, 4, or 5.intThe interval in milliseconds between eachevent callback, which enables an application to abort certain method calls before they complete.AbortCheckbooleanThis applies only to creating digital signatures.intThe initial counter for theChaCha20encryption algorithm, which has a default value of 0, is pre-agreed by both the encryptor and decryptor.intThe iteration count in password-based encryption (PBE) establishes the computational difficulty for encryption and decryption, thereby enhancing resistance to exhaustive search attacks.intThe key lengthin bitsfor symmetric encryption algorithms.booleanSee the documentation for theproperty.getFirstChunk()voidgetLastJsonData(JsonObject json)Offers details on the last method executed.Selects the MAC algorithm to be used for any of the Mac methods, such as MacStringENC, MacBytes, etc.intThis property is set upon verifying a digital signature and indicates the number of signer certificates.Selects the hash algorithm for use within OAEP padding when encrypting usingpkiwith RSAES-OAEP.Selects the MGF hash algorithm for use within OAEP padding when encrypting usingpkiwith RSAES-OAEP.booleanSelects the RSA encryption scheme when encrypting usingpki(with a certificate and private key).intThis property defines the padding scheme Chilkat uses for adding padding to input data during encryption and removing it during decryption.If theproperty is set togetCryptAlgorithm()pbes1orpbes2, this property defines the symmetric encryption algorithm to be used for password-based encryption (PBE).This property determines the underlying symmetric encryption algorithm when theproperty is set togetCryptAlgorithm()pkifor selecting PKCS7 public-key encryption.Returns the installed listener, ornull.intThe effective key length (in bits) for theRC2encryption algorithm.getSignatureSigningTimeStr(int index)This method retrieves the signing time of the Nth certificate in a digital signature after verification.booleangetSignedAttributes(int signerIndex, BinData pkcs7Der, StringBuilder sbJson)Extracts the signed (authenticated) attributes for the Nth signer, wheresignerIndexis typically 0, as most signatures have only one signer.This property applies when creating RSA signatures.Contains JSON to specify the authenticated (signed) attributes or unauthenticated (unsigned) attributes that are to be included in CMS signatures.This is a catch-all property to be used for uncommon needs.When UU encoding, this is the filename to be embedded in UU encoded output.When UU encoding, this is the file permissions mode to be embedded in UU encoded output.Hashes the bytes inbdand returns the hash as a binary-encoded string.voidhashBeginString(String strData)To hash a large amount of text, start by processing the first chunk using this method.voidhashChunkBd(boolean firstChunk, BinData bd)Start or continue hashing data in chunks.hashFileENC(String path)Hashes a file and returns the hash as an encoded string.Finalizes a multi-step hash computation and returns the hash bytes encoded according to theproperty setting.getEncodingMode()voidhashMoreString(String strData)Adds more text to the hash currently under computation.hashStringENC(String str)Hashes thestrand returns the hash as a binary encoded string.booleanhasSignatureSigningTime(int index)After verifying a digital signature with a signature verification method, you can call this method.hotp(String secret, String secretEnc, String counterHex, int numDigits, int truncOffset, String hashAlg)Implements RFC 4226: HOTP: An HMAC-Based One-Time Password Algorithm.voidlastDecryptCert(Cert cert)Returns incertthe last certificate used for public-key decryption.voidlastSignerCert(int index, Cert cert)Retrieves the Nth certificate used for signing incert, where the first certificate is at index 0.Generates a Message Authentication Code (MAC) for the bytes inbdusing the algorithm defined by theproperty.getMacAlgorithm()macStringENC(String inText)Computes a Message Authentication Code (MAC) and returns it as a binary encoded string.mySqlAesDecrypt(String strEncryptedHex, String strPassword)MatchesMySQL'sAES_DECRYPTfunction.mySqlAesEncrypt(String strData, String strPassword)This function replicatesMySQL'sAES_ENCRYPT, returning the encrypted data as a hex-encoded string.voidonAbortCheck(BooleanSupplier callback)Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it.voidonPercentDone(IntPredicate callback)Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it.voidonProgressInfo(BiConsumer<String,String> callback)Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds.voidopaqueSignBd(BinData bd)Digitally signs the contents ofbd.opaqueSignStringENC(String str)Digitally signs a string and returnsPKCS#7 signed-dataas abinary encoded string.voidopaqueVerifyBd(BinData bd)The method performs in-place verification of thePKCS#7 signed-datacontent ofbd.opaqueVerifyStringENC(String p7m)This function verifies aPKCS#7 signed-databinary-encoded signature and returns the original text data.pbkdf1(String password, String charset, String hashAlg, String salt, int iterationCount, int outputKeyBitLen, String encoding)This function implements thePBKDF1(Password-Based Key Derivation Function #1) algorithm.pbkdf2(String password, String charset, String hashAlg, String salt, int iterationCount, int outputKeyBitLen, String encoding)Implements thePBKDF2algorithm as follows: Convertpasswordto the character encoding specified bycharsetbefore using it in the key derivation function.voidSets the initialization vector (IV) to a random value.This method converts between different encodings, such as frombase64tohex.voidsetAbortCurrent(boolean value)Sets theAbortCurrentproperty; seegetAbortCurrent().voidsetBCryptWorkFactor(int value)Sets theBCryptWorkFactorproperty; seegetBCryptWorkFactor().voidsetCadesEnabled(boolean value)Sets theCadesEnabledproperty; seegetCadesEnabled().voidsetCadesSigPolicyHash(String value)Sets theCadesSigPolicyHashproperty; seegetCadesSigPolicyHash().voidsetCadesSigPolicyId(String value)Sets theCadesSigPolicyIdproperty; seegetCadesSigPolicyId().voidsetCadesSigPolicyUri(String value)Sets theCadesSigPolicyUriproperty; seegetCadesSigPolicyUri().voidsetCharset(String value)Sets theCharsetproperty; seegetCharset().voidsetCipherMode(String value)Sets theCipherModeproperty; seegetCipherMode().voidsetCmsOptions(String value)Sets theCmsOptionsproperty; seegetCmsOptions().voidsetCryptAlgorithm(String value)Sets theCryptAlgorithmproperty; seegetCryptAlgorithm().voidsetDecryptCert(Cert cert)Sets the digital certificate for decryption when theproperty is set togetCryptAlgorithm()"pki".voidsetDecryptCert2(Cert cert, PrivateKey key)Sets the digital certificate and associated private key for decryption when theproperty is set togetCryptAlgorithm()"pki".voidsetEncodedAad(String aadStr, String encoding)Sets the optional authenticated additional data (AAD) for AES encryption inGCMmode.voidsetEncodedAuthTag(String authTagStr, String encoding)In GCM mode, the authentication tag is a short value (e.g.voidsetEncodedIV(String ivStr, String encoding)Sets the initialization vector used in symmetric encrpytion (AES,Blowfish, etc.) from a binary-encoded string using any Chilkat-supported encoding method (e.g.,base64,hex).voidsetEncodedKey(String keyStr, String encoding)Sets the encryption key used in symmetric encryption (AES,Blowfish, etc.) from a binary-encoded string using any Chilkat-supported encoding method (e.g.,base64,hex).voidsetEncodedSalt(String saltStr, String encoding)Sets thepbes2orpbes1salt bytes from a binary-encoded string using any Chilkat-supported encoding method (e.g.,base64,hex).voidsetEncodingMode(String value)Sets theEncodingModeproperty; seegetEncodingMode().voidsetEncryptCert(Cert cert)Instructs the encryption library to use a specified digital certificate for public-key encryption.voidsetFirstChunk(boolean value)Sets theFirstChunkproperty; seegetFirstChunk().voidsetHashAlgorithm(String value)Sets theHashAlgorithmproperty; seegetHashAlgorithm().voidsetHavalRounds(int value)Sets theHavalRoundsproperty; seegetHavalRounds().voidsetHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().voidsetIncludeCertChain(boolean value)Sets theIncludeCertChainproperty; seegetIncludeCertChain().voidsetInitialCount(int value)Sets theInitialCountproperty; seegetInitialCount().voidsetIterationCount(int value)Sets theIterationCountproperty; seegetIterationCount().voidsetKeyLength(int value)Sets theKeyLengthproperty; seegetKeyLength().voidsetLastChunk(boolean value)Sets theLastChunkproperty; seegetLastChunk().voidsetMacAlgorithm(String value)Sets theMacAlgorithmproperty; seegetMacAlgorithm().voidsetMacKeyEncoded(String key, String encoding)Sets the MAC key from a binary-encoded string using any Chilkat-supported encoding method (e.g.,base64,hex).voidsetMacKeyString(String key)Sets the MAC key from a string.voidsetOaepHash(String value)Sets theOaepHashproperty; seegetOaepHash().voidsetOaepMgfHash(String value)Sets theOaepMgfHashproperty; seegetOaepMgfHash().voidsetOaepPadding(boolean value)Sets theOaepPaddingproperty; seegetOaepPadding().voidsetPaddingScheme(int value)Sets thePaddingSchemeproperty; seegetPaddingScheme().voidsetPbesAlgorithm(String value)Sets thePbesAlgorithmproperty; seegetPbesAlgorithm().voidsetPbesPassword(String value)Sets thePbesPasswordproperty; seegetPbesPassword().voidsetPkcs7CryptAlg(String value)Sets thePkcs7CryptAlgproperty; seegetPkcs7CryptAlg().voidsetProgressListener(ProgressListener listener)Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.voidsetRc2EffectiveKeyLength(int value)Sets theRc2EffectiveKeyLengthproperty; seegetRc2EffectiveKeyLength().voidsetSigningAlg(String value)Sets theSigningAlgproperty; seegetSigningAlg().voidsetSigningAttributes(String value)Sets theSigningAttributesproperty; seegetSigningAttributes().voidsetSigningCert(Cert cert)Sets the digital certificate to be used for signing.voidsetSigningCert2(Cert cert, PrivateKey privateKey)Sets the digital certificate and associated private key for signing.voidsetTsaHttpObj(Http http)If timestamp server communications are needed for signing and special Internet settings like a proxy server are necessary, this method can provide an Http object configured with these settings.voidsetUncommonOptions(String value)Sets theUncommonOptionsproperty; seegetUncommonOptions().voidsetUuFilename(String value)Sets theUuFilenameproperty; seegetUuFilename().voidSets theUuModeproperty; seegetUuMode().voidsetVerifyCert(Cert cert)Assigns the digital certificate for signature verification.Digitally signs the content indataToSignand returns adetachedsignature (PKCS#7 signed-data) as a binary-encoded string.signHashENC(String encodedHash, String hashAlg, String hashEncoding)Digitally signs a pre-computed hash and returns adetachedsignature (PKCS#7 signed-data) as a binary-encoded string.signSbENC(StringBuilder sb)Digitally signs the text contained insband returns adetachedsignature (PKCS#7 signed-data) as a binary-encoded string.signStringENC(String str)Digitally signs a string and returns adetachedsignature (PKCS#7 signed-data) as a binary-encoded string.totp(String secret, String secretEnc, String t0, String tNow, int tStep, int numDigits, int truncOffset, String hashAlg)Implements RFC 6238: TOTP: Time-Based One-Time Password Algorithm.voiduseCertVault(XmlCertVault vault)Adds an XML certificate vault to the object's internal list of sources to be searched for certificates and private keys when encrypting/decrypting or signing/verifying.voidverifyBdENC(BinData data, String encodedSig)Verifies adetached digital signatureagainst the original data contained indata.voidVerifies anopaque digital signaturecontained in a.p7mfile and extracts the original data todestPath.voidVerifies adetached digital signaturecontained in a.p7sfile against the original data contained inoriginalDataPath.voidverifySbENC(StringBuilder sb, String encodedSig)Verifies adetached digital signatureagainst the original text contained insb.voidverifyStringENC(String str, String encodedSig)Verifies adetached digital signatureagainst the original text instr.voidxtsSetDataUnitNumber(long loUint32, long hiUint32)Sets the XTS-AES mode data unit number.voidxtsSetEncodedTweakKey(String key, String encoding)Sets the XTS-AES mode tweak key from an encoded string.voidxtsSetEncodedTweakValue(String tweak, String encoding)Sets the XTS-AES mode tweak value from an encoded string.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Crypt2
public Crypt2()Creates a newCrypt2object.
-
-
Method Details
-
getAbortCurrent
public boolean getAbortCurrent()Setting this property totruewill abort the current method, but only for those methods having anAsyncalternative. The property automatically resets tofalseat the start of each method and after an abort. Both synchronous and asynchronous methods can be aborted; synchronous methods require setting this property from another thread.- Returns:
- the value of the
AbortCurrentproperty
-
setAbortCurrent
public void setAbortCurrent(boolean value)Sets theAbortCurrentproperty; seegetAbortCurrent().- Parameters:
value- the new value
-
getBCryptWorkFactor
public int getBCryptWorkFactor()The BCrypt work factor determines the computational cost ofandbCryptHash(String). It represents the base-2 logarithm of the number of hashing rounds. For instance, a work factor of 12 corresponds to 2^12 hashing rounds. This cost factor is designed to make computations challenging enough to deter brute-force attacks.bCryptVerify(String, String)The work factor must be set between 4 and 31, inclusive, with a
default value of 10.- Returns:
- the value of the
BCryptWorkFactorproperty
-
setBCryptWorkFactor
public void setBCryptWorkFactor(int value)Sets theBCryptWorkFactorproperty; seegetBCryptWorkFactor().- Parameters:
value- the new value
-
getBlockSize
public int getBlockSize()This property indicates the block size in bytes for the chosen encryption algorithm. For instance, if theis set togetCryptAlgorithm()AES, the BlockSize is automatically set to 16 bytes. In contrast, the block size for theChaCha20streaming algorithm is 1 byte.- Returns:
- the value of the
BlockSizeproperty (read-only)
-
getCadesEnabled
public boolean getCadesEnabled()This property applies to allPKCS7signature creation methods. When set totrue, it ensures the inclusion of required attributes (such ascontent-type,message-digest, andsigning-certificate-v2) to qualify the signature as at least aCAdES-BESsignature. By default, this property is set tofalse.- Returns:
- the value of the
CadesEnabledproperty
-
setCadesEnabled
public void setCadesEnabled(boolean value)Sets theCadesEnabledproperty; seegetCadesEnabled().- Parameters:
value- the new value
-
getCadesSigPolicyHash
This property is for PKCS7 CMS signatures that wish to include CAdESsignature policy attributes. Set it to thebase64-encoded hash of the policy document at theusing eithergetCadesSigPolicyUri()SHA256orSHA1.- Returns:
- the value of the
CadesSigPolicyHashproperty
-
setCadesSigPolicyHash
Sets theCadesSigPolicyHashproperty; seegetCadesSigPolicyHash().- Parameters:
value- the new value (notnull)
-
getCadesSigPolicyId
This property is for PKCS7 CMS signatures that wish to include CAdESsignature policy attributes. TheCAdES Signature Policy IDis an object identifier (OID) included in a CAdES signature that specifies the exact signature policy the signer followed. It is the OID associated with the policy URL. An example OID would look like this:2.16.840.1.101.3.2.1.48.1An application that wishes to include signature policy attributes should set all three properties:
,getCadesSigPolicyHash(), andgetCadesSigPolicyUri().getCadesSigPolicyId()- Returns:
- the value of the
CadesSigPolicyIdproperty
-
setCadesSigPolicyId
Sets theCadesSigPolicyIdproperty; seegetCadesSigPolicyId().- Parameters:
value- the new value (notnull)
-
getCadesSigPolicyUri
This property is for PKCS7 CMS signatures that wish to include CAdESsignature policy attributes. Thesignature policy URIin aCAdESdigital signature is a link that points to a document describing the rules and conditions under which the signature was created. Typically the Signature Policy URI in a CAdES signature points to a.derfile, not a PDF or human-readable document.For example:
http://example.com/policies/my-policy.der- Returns:
- the value of the
CadesSigPolicyUriproperty
-
setCadesSigPolicyUri
Sets theCadesSigPolicyUriproperty; seegetCadesSigPolicyUri().- Parameters:
value- the new value (notnull)
-
getCharset
This property specifies the character encoding used to represent text as bytes for encryption and hashing. By default, it uses the computer'sANSIcharset, such asWindows-1252for locales like the United States, United Kingdom, Western Europe, Australia, and New Zealand.Most applications are advised to set this property to
UTF-8. Chilkat plans to change its default to UTF-8 in a future major version to align with current standards. The current default of ANSI stems from a time when UTF-8 was not widely adopted.- Returns:
- the value of the
Charsetproperty
-
setCharset
Sets theCharsetproperty; seegetCharset().- Parameters:
value- the new value (notnull)
-
getCipherMode
Sets thecipher modefor block encryption algorithms (AES, Blowfish,TwoFish, DES, 3DES, RC2). Possible values areCBC(the default) ,ECB,CTR,OFB,GCM, andCFB. These acronyms have the following meanings:CBC: Cipher Block Chaining,ECB: Electronic CookBookCTR: Counter ModeCFB: Cipher FeedbackOFB: Output FeedbackGCM: Galois/Counter ModeXTS: AES-XTS (starting in Chilkat v9.5.0.91, only works with AES encryption)
The
GCM(Galois/Counter Mode) is available with any cipher having a 16-byte block size, such as AES. The CFB, OFB, CTR, and GCM modes convert block ciphers into stream ciphers. In these modes of operation, theproperty is unused because no padding occurs.getPaddingScheme()Starting in v9.5.0.91 Chilkat supports
AES-XTSmode. XTS mode additionally uses a tweak key and tweak value, which are set via the,xtsSetEncodedTweakKey(String, String), andxtsSetEncodedTweakValue(String, String). (The latter two functions provide alternative means of setting the tweak value.) Chilkat fully supports AES-XTS mode withxtsSetDataUnitNumber(long, long)ciphertext-stealing, which means it will correctly encrypt/decrypt data with size not divisible by the block size (i.e. divisible by 16 bytes).- Returns:
- the value of the
CipherModeproperty
-
setCipherMode
Sets theCipherModeproperty; seegetCipherMode().- Parameters:
value- the new value (notnull)
-
getCmsOptions
A JSON string to manage additional CMS (PKCS7) signature and validation options. Possible options are:- boolean
OmitAlgorithmIdNull: Set this JSON member totrueto omit the explicit NULL within an AlgorithmIdentifier ASN.1 within the PKCS7. This should almost never be used, but helps for rare cases where a validator dislikes the explicit NULL being present. - boolean
ValidateTimestampTokens: Tells Chilkat to also validate the timestamp tokens when validating a signature that includes a timestamp. - boolean
ConstructedOctets: When set totrue, tells Chilkat to use theASN.1 constructed octetsformat for the data contained in the CMS (PKCS7) signed-data. - boolean
CanonicalizeITIDA: This applies toEgypt ITIDA, which requires signed documents in a CAdES-BES CMS format, using ITIDA’s JSON canonicalization (for JSON payloads), with only the Base64‑encoded signature attached - not the original data itself. When set totrue, Chilkat willautomatically do the special ITIDA JSON canonicalization.
- Returns:
- the value of the
CmsOptionsproperty
- boolean
-
setCmsOptions
Sets theCmsOptionsproperty; seegetCmsOptions().- Parameters:
value- the new value (notnull)
-
getCryptAlgorithm
Selects the encryption algorithm for encrypting and decrypting. Possible values are:Algorithm Type Symmetric? Key Size(s) Block/Stream Mode of Operation Notes
aesBlock cipher ✔ Yes 128, 192, 256 bits Block (128-bit) CBC, CTR, GCM, etc. Widely used, FIPS-approvedpki(Public-Key Encryption) Asymmetric ✗ No 1024–4096+ bits N/A N/A Used for key exchange, not bulk datachacha20Stream cipher ✔ Yes 256 bits Stream N/A High speed, secure, designed for simplicitydesBlock cipher ✔ Yes 56 bits Block (64-bit) ECB, CBC, etc. Deprecated, insecure3desBlock cipher ✔ Yes 112 or 168 bits Block (64-bit) ECB, CBC, etc. Legacy use, weak by modern standardsrc2Block cipher ✔ Yes 40–128 bits (variable) Block (64-bit) ECB, CBC, etc. Obsolete, variable strengthblowfish2(Blowfish) Block cipher ✔ Yes 32–448 bits (variable) Block (64-bit) ECB, CBC, etc. Fast, but 64-bit block size is a limitationtwofishBlock cipher ✔ Yes Up to 256 bits Block (128-bit) ECB, CBC, etc. AES finalist, secure and flexiblepbes1Key derivation ✔ Yes Based on underlying cipher Block (varies) PKCS#5 v1.5 Obsolete, uses DES/RC2pbes2Key derivation ✔ Yes Based on underlying cipher Block (varies) PKCS#5 v2.0 Modern, supports AES, SHA, etc.arc4(RC4) Stream cipher ✔ Yes 40–2048 bits (variable) Stream N/A Deprecated, insecure due to biases- Returns:
- the value of the
CryptAlgorithmproperty
-
setCryptAlgorithm
Sets theCryptAlgorithmproperty; seegetCryptAlgorithm().- Parameters:
value- the new value (notnull)
-
getEncodingMode
The EncodingMode property specifies thebinary encodingformat (e.g.,base64,hex,base58,base64url) used by functions ending in"ENC", likeandencryptStringENC(String). For encryption functions, EncodingMode determines the encoding of the output. For decryption functions, it specifies the encoding of the input data.decryptStringENC(String)A
list of supported binary encodingsis available at the link below.The default value is
base64- Returns:
- the value of the
EncodingModeproperty
-
setEncodingMode
Sets theEncodingModeproperty; seegetEncodingMode().- Parameters:
value- the new value (notnull)
-
getFirstChunk
public boolean getFirstChunk()Using theFirstChunkandproperties is the way to do streaming encryption or decryption with Chilkat.getLastChunk()By default, both FirstChunk and LastChunk are set to
true, indicating that the data passed to the encryption or decryption method is the full amount. To process data in multiple chunks, adjust these settings as follows:1. For the first chunk, set FirstChunk =
trueand LastChunk =false.
2. For intermediate chunks, set both FirstChunk =falseand LastChunk =false.
3. For the final chunk, set FirstChunk =falseand LastChunk =true.You can feed data chunks of any size, regardless of the encryption algorithm's block size (e.g., 16 bytes for AES). Chilkat will handle buffering and, upon receiving the final chunk, pad the output to the appropriate block size according to the selected
.getPaddingScheme()- Returns:
- the value of the
FirstChunkproperty
-
setFirstChunk
public void setFirstChunk(boolean value)Sets theFirstChunkproperty; seegetFirstChunk().- Parameters:
value- the new value
-
getHashAlgorithm
Selects the hash algorithm used by methods that create hashes. The valid choices aresha256,sha384,sha512,sha3-224,sha3-256,sha3-384,sha3-512,sha1,md2,md5,haval,ripemd128,ripemd160,ripemd256, orripemd320.(Chilkat supports
SHA-2because it includes the SHA-256, SHA-384, and SHA-512 hash functions.)The default value is
sha256.Note: The HAVAL hash algorithm is affected by two other properties:
andgetHavalRounds().getKeyLength()- The HavalRounds may have values of 3, 4, or 5.
- For HAVAL hashing, the KeyLength can be 128, 160, 192, 224, or 256.
- Returns:
- the value of the
HashAlgorithmproperty
-
setHashAlgorithm
Sets theHashAlgorithmproperty; seegetHashAlgorithm().- Parameters:
value- the new value (notnull)
-
getHavalRounds
public int getHavalRounds()Applies to the HAVAL hash algorithm only and must be set to the integer value 3, 4, or 5. The default value is 3.- Returns:
- the value of the
HavalRoundsproperty
-
setHavalRounds
public void setHavalRounds(int value)Sets theHavalRoundsproperty; seegetHavalRounds().- Parameters:
value- the new value
-
getHeartbeatMs
public int getHeartbeatMs()The interval in milliseconds between eachevent callback, which enables an application to abort certain method calls before they complete. By default, HeartbeatMs is set toAbortCheck0, meaning no AbortCheck event callbacks will trigger.Methods with event callbacks include:
,ckDecryptFile(String, String),ckEncryptFile(String, String), andHashFile.hashFileENC(String)- Returns:
- the value of the
HeartbeatMsproperty
-
setHeartbeatMs
public void setHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().- Parameters:
value- the new value
-
getIncludeCertChain
public boolean getIncludeCertChain()This applies only to creating digital signatures. By default (true), any additional certificates in the authentication chain are included in the PKCS7 digital signature.- Returns:
- the value of the
IncludeCertChainproperty
-
setIncludeCertChain
public void setIncludeCertChain(boolean value)Sets theIncludeCertChainproperty; seegetIncludeCertChain().- Parameters:
value- the new value
-
getInitialCount
public int getInitialCount()The initial counter for theChaCha20encryption algorithm, which has a default value of 0, is pre-agreed by both the encryptor and decryptor.- Returns:
- the value of the
InitialCountproperty
-
setInitialCount
public void setInitialCount(int value)Sets theInitialCountproperty; seegetInitialCount().- Parameters:
value- the new value
-
getIterationCount
public int getIterationCount()The iteration count in password-based encryption (PBE) establishes the computational difficulty for encryption and decryption, thereby enhancing resistance to exhaustive search attacks. The default iteration count is1024, which is considered low, so it is recommended that applications increase this number when usingpbes2encryption.PBES2 Iteration Count Recommendations
Aim for a 100–200 ms derive time on your target hardware.
-
Server/Desktop:
100000 – 1000000+ -
Mobile/Embedded:
50000 - 100000
Benchmark annually and increase iterations as hardware improves.
- Returns:
- the value of the
IterationCountproperty
-
Server/Desktop:
-
setIterationCount
public void setIterationCount(int value)Sets theIterationCountproperty; seegetIterationCount().- Parameters:
value- the new value
-
getKeyLength
public int getKeyLength()The key lengthin bitsfor symmetric encryption algorithms. The default value is256.- Returns:
- the value of the
KeyLengthproperty
-
setKeyLength
public void setKeyLength(int value)Sets theKeyLengthproperty; seegetKeyLength().- Parameters:
value- the new value
-
getLastChunk
public boolean getLastChunk()See the documentation for theproperty.getFirstChunk()- Returns:
- the value of the
LastChunkproperty
-
setLastChunk
public void setLastChunk(boolean value)Sets theLastChunkproperty; seegetLastChunk().- Parameters:
value- the new value
-
getMacAlgorithm
Selects the MAC algorithm to be used for any of the Mac methods, such as MacStringENC, MacBytes, etc. The default value ishmac. Possible values arehmacandpoly1305.- Returns:
- the value of the
MacAlgorithmproperty
-
setMacAlgorithm
Sets theMacAlgorithmproperty; seegetMacAlgorithm().- Parameters:
value- the new value (notnull)
-
getNumSignerCerts
public int getNumSignerCerts()This property is set upon verifying a digital signature and indicates the number of signer certificates. You can retrieve each signing certificate using themethod with an index ranging fromlastSignerCert(int, Cert)0toNumSignerCerts-1.- Returns:
- the value of the
NumSignerCertsproperty (read-only)
-
getOaepHash
Selects the hash algorithm for use within OAEP padding when encrypting usingpkiwith RSAES-OAEP. The valid choices aresha1,sha256,sha384,sha512,The default value is
sha256- Returns:
- the value of the
OaepHashproperty
-
setOaepHash
Sets theOaepHashproperty; seegetOaepHash().- Parameters:
value- the new value (notnull)
-
getOaepMgfHash
Selects the MGF hash algorithm for use within OAEP padding when encrypting usingpkiwith RSAES-OAEP. The valid choices aresha1,sha256,sha384,sha512, The default issha256.- Returns:
- the value of the
OaepMgfHashproperty
-
setOaepMgfHash
Sets theOaepMgfHashproperty; seegetOaepMgfHash().- Parameters:
value- the new value (notnull)
-
getOaepPadding
public boolean getOaepPadding()Selects the RSA encryption scheme when encrypting usingpki(with a certificate and private key). The default value isfalse, which selects RSAES_PKCS1-V1_5. If set totrue, then RSAES_OAEP is used.- Returns:
- the value of the
OaepPaddingproperty
-
setOaepPadding
public void setOaepPadding(boolean value)Sets theOaepPaddingproperty; seegetOaepPadding().- Parameters:
value- the new value
-
getPaddingScheme
public int getPaddingScheme()This property defines the padding scheme Chilkat uses for adding padding to input data during encryption and removing it during decryption. It is applicable only to symmetric block ciphers, such as AES, Blowfish, and Twofish, which require input sizes matching their exact block size. Padding ensures the last block is completely filled.The possible values are:
-
PKCS#5/PKCS#7 (RFC 1423)
default
Each pad byte = number of padding bytes.
Block size: 8
Data: "HELLO" (5 bytes)
Padding: 0x03 0x03 0x03 -
FIPS 81
Last byte = count; others = random.
Block size: 8
Data: "HELLO"
Padding: 0xA4 0x2F 0x9C 0x03 -
Random
All pad bytes random; decryptor must know original length.
Block size: 8
Data: "HELLO"
Padding: 0x7D 0x20 0xCB 0x81 -
Null (0x00)
Pad with zeros; no padding if already exact.
Block size: 8
Data: "HEL" (3 bytes)
Padding: 0x00 0x00 0x00 0x00 0x00 -
Space (0x20)
Pad with spaces; no padding if already exact.
Block size: 8
Data: "HEL" (3 bytes)
Padding: 0x20 0x20 0x20 0x20 0x20
- Returns:
- the value of the
PaddingSchemeproperty
-
PKCS#5/PKCS#7 (RFC 1423)
-
setPaddingScheme
public void setPaddingScheme(int value)Sets thePaddingSchemeproperty; seegetPaddingScheme().- Parameters:
value- the new value
-
getPbesAlgorithm
If theproperty is set togetCryptAlgorithm()pbes1orpbes2, this property defines the symmetric encryption algorithm to be used for password-based encryption (PBE). The default is"des". Applications should set this property equal to"aes".- Returns:
- the value of the
PbesAlgorithmproperty
-
setPbesAlgorithm
Sets thePbesAlgorithmproperty; seegetPbesAlgorithm().- Parameters:
value- the new value (notnull)
-
getPbesPassword
- Returns:
- the value of the
PbesPasswordproperty
-
setPbesPassword
Sets thePbesPasswordproperty; seegetPbesPassword().- Parameters:
value- the new value (notnull)
-
getPkcs7CryptAlg
This property determines the underlying symmetric encryption algorithm when theproperty is set togetCryptAlgorithm()pkifor selecting PKCS7 public-key encryption.The default is
aes.- Returns:
- the value of the
Pkcs7CryptAlgproperty
-
setPkcs7CryptAlg
Sets thePkcs7CryptAlgproperty; seegetPkcs7CryptAlg().- Parameters:
value- the new value (notnull)
-
getRc2EffectiveKeyLength
public int getRc2EffectiveKeyLength()The effective key length (in bits) for theRC2encryption algorithm. When using RC2, set both theand Rc2EffectiveKeyLength properties to values between 8 and 1024, inclusive. The default setting for both is 128.getKeyLength()The default value is
128RC2 is an old symmetric encryption algorithm, now considered insecure due to its small key size and vulnerability to cryptanalysis. Modern algorithms like AES are recommended instead.
- Returns:
- the value of the
Rc2EffectiveKeyLengthproperty
-
setRc2EffectiveKeyLength
public void setRc2EffectiveKeyLength(int value)Sets theRc2EffectiveKeyLengthproperty; seegetRc2EffectiveKeyLength().- Parameters:
value- the new value
-
getSigningAlg
This property applies when creating RSA signatures.It defines the
RSA signature scheme. The default isPKCS1-v1_5. You can change it toRSASSA-PSS(orpss) to use the RSASSA-PSS signature scheme.-
PKCS#1 v1.5
Older, deterministic scheme.
- Simple padding.
- Vulnerable to certain attacks if not used carefully.
- Still widely used for compatibility. -
RSASSA-PSS
Newer, probabilistic scheme (recommended by modern standards).
- Adds random salt for each signature.
- More secure against chosen-plaintext and padding oracle attacks.
- Recommended by modern standards like PKCS#1 v2.1 and FIPS.
- Returns:
- the value of the
SigningAlgproperty
-
PKCS#1 v1.5
-
setSigningAlg
Sets theSigningAlgproperty; seegetSigningAlg().- Parameters:
value- the new value (notnull)
-
getSigningAttributes
Contains JSON to specify the authenticated (signed) attributes or unauthenticated (unsigned) attributes that are to be included in CMS signatures. The default value is:{ "contentType": true, "signingTime": true, "messageDigest": true }- Returns:
- the value of the
SigningAttributesproperty
-
setSigningAttributes
Sets theSigningAttributesproperty; seegetSigningAttributes().- Parameters:
value- the new value (notnull)
-
getUncommonOptions
This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.Can be set to a list of the following comma separated keywords:
UseConstructedOctets- Introduced in v9.5.0.83. When creating opaque CMS signatures (signatures that embed the data being signed), will use theconstructed octetsform of the ASN.1 that holds the data. This is to satify some validators that are brittle/fragile/picky and require a particular format, such as for the ICP-Brazil Digital Signature Standard.
- Returns:
- the value of the
UncommonOptionsproperty
-
setUncommonOptions
Sets theUncommonOptionsproperty; seegetUncommonOptions().- Parameters:
value- the new value (notnull)
-
getUuFilename
When UU encoding, this is the filename to be embedded in UU encoded output. The default isfile.dat. When UU decoding, this is the filename found in the UU encoded input.- Returns:
- the value of the
UuFilenameproperty
-
setUuFilename
Sets theUuFilenameproperty; seegetUuFilename().- Parameters:
value- the new value (notnull)
-
getUuMode
When UU encoding, this is the file permissions mode to be embedded in UU encoded output. The default is644. When UU decoding, this property is set to the mode found in the UU encoded input.- Returns:
- the value of the
UuModeproperty
-
setUuMode
Sets theUuModeproperty; seegetUuMode().- Parameters:
value- the new value (notnull)
-
addEncryptCert
Adds a certificate for public-key encryption. To enable public-key encryption with digital certificates, set theproperty togetCryptAlgorithm()pki. Callseparately for each certificate you wish to use for encryption.addEncryptCert(Cert)Any of the
Encrypt*methods will doRSA public-key encryptionwhen theCryptAlgorithmis set to the keywordpki. The output is aPKCS#7 enveloped-datasecure container.- Parameters:
cert- thecertargument (notnull)
-
addPfxSourceBd
Adds aPFXfile to the object's list of sources for locating certificates and private keys during public-key decryption or signing. To add multiple PFX sources, call this method multiple times.bdshould contain the bytes of a PFX file (also known asPKCS12or.p12).Note: Information about the certificate(s) needed for
public-key decryptionare included in thePKCS#7 enveloped-data. Chilkat will automatically find a usable certificate and private key from sources like Windows certificate stores, the Apple keychain, or other sources provided by the application.- Parameters:
bd- thebdargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPfxSourceFile
Adds aPFXfile to the object's list of sources for locating certificates and private keys during public-key decryption or signing. To add multiple PFX sources, call this method multiple times.Note: Information about the certificate(s) needed for
public-key decryptionare included in thePKCS#7 enveloped-data. Chilkat will automatically find a usable certificate and private key from sources like Windows certificate stores, the Apple keychain, or other sources provided by the application.- Parameters:
pfxFilePath- thepfxFilePathargument (notnull)pfxPassword- thepfxPasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addSigningCert
Call this method once per certificate to addmultiple certificates for signing. If signing with a single certificate, then theSetSigningCertorSetSigningCert2methods can be used instead.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
aesKeyUnwrap
Implements theAES Key Wrap Algorithm(RFC 3394) for unwrapping. Thekekis theKey Encryption Key(the AES key used to unwrap thewrappedKeyData). The arguments and return value are binary encoded strings using the encoding specified byencoding(which can bebase64,hex,base64url, etc.) The full list of supported encodings is available at the link below.The
kekshould be anAES keyof16 bytes,24 bytes, or32 bytes(i.e. 128-bits, 192- bits, or 256-bits). For example, if passed as a hex string, then thekekshould be 32 chars in length, 48 chars, or 64 chars (because each byte is represented as 2 chars in hex).The
wrappedKeyDatacontains the data to be unwrapped. The result, if decoded, is 8 bytes less than the wrapped key data. For example, if a 256-bit AES key (32 bytes) is wrapped, the size of the wrapped key data is 40 bytes. Unwrapping restores it to the original 32 bytes.- Parameters:
kek- thekekargument (notnull)wrappedKeyData- thewrappedKeyDataargument (notnull)encoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
aesKeyUnwrapWithPadding
Implements theAES Key Wrap with Padding Algorithm(RFC 5649) for unwrapping. Thekekis theKey Encryption Key(the AES key used to unwrap thewrappedKeyData). The arguments and return value are binary encoded strings using the encoding specified byencoding(which can bebase64,hex,base64url, etc.)The
kekshould be anAES keyof16 bytes,24 bytes, or32 bytes(i.e. 128-bits, 192- bits, or 256-bits). For example, if passed as a hex string, then thekekshould be 32 chars in length, 48 chars, or 64 chars (because each byte is represented as 2 chars in hex).The
wrappedKeyDatacontains the data to be unwrapped.The unwrapped key is returned as an encoded string (using the encoding specified in
encoding).- Parameters:
kek- thekekargument (notnull)wrappedKeyData- thewrappedKeyDataargument (notnull)encoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
aesKeyWrap
Implements theAES Key Wrap Algorithm(RFC 3394). Thekekis theKey Encryption Key(the AES key used to encrypt thekeyData). The arguments and return value are binary encoded strings using the encoding specified byencoding(which can bebase64,hex,base64url, etc.) The full list of supported encodings is available at the link below.The
kekshould be anAES keyof16 bytes,24 bytes, or32 bytes(i.e. 128-bits, 192- bits, or 256-bits). For example, if passed as a hex string, then thekekshould be 32 chars in length, 48 chars, or 64 chars (because each byte is represented as 2 chars in hex).The
keyDatacontains the data to be key wrapped. It must be a multiple of 64-bits in length. In other words, if thekeyDatais decoded to binary, it should be a number of bytes that is a multiple of 8.The return string, if decoded to binary bytes, is equal to the size of the key data + 8 additional bytes.
- Parameters:
kek- thekekargument (notnull)keyData- thekeyDataargument (notnull)encoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
aesKeyWrapWithPadding
Implements theAES Key Wrap with Padding Algorithm(RFC 5649). Thekekis theKey Encryption Key(the AES key used to encrypt thekeyData). The arguments and return value are binary encoded strings using the encoding specified byencoding(which can bebase64,hex,base64url, etc.)The
kekshould be anAES keyof16 bytes,24 bytes, or32 bytes(i.e. 128-bits, 192- bits, or 256-bits). For example, if passed as a hex string, then thekekshould be 32 chars in length, 48 chars, or 64 chars (because each byte is represented as 2 chars in hex).The
keyDatacontains the data to be key wrapped.Returns the wrapped key using the encoding specified in
encoding.- Parameters:
kek- thekekargument (notnull)keyData- thekeyDataargument (notnull)encoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
argon2DeriveKey
Derives a key from a password using Argon2, the memory-hard key derivation function specified in RFC 9106. Argon2 is deliberately expensive in both CPU time and memory, which is what makes a brute-force search of the password space costly.passwordis the password.jsonis a JSON string containing the Argon2 options (described below). The derived key is returned inbdKey, which is cleared before the derived key is stored in it.A
saltmember is required injson. There is no default, because a key derivation salt is chosen and stored by the application. Useto generate one.genRandomBytesENC(int)Every other member is optional. Passing an empty string for
jsonis the same as passing{}and would fail only because no salt was given.The JSON is validated strictly before it is used, so malformed JSON is rejected rather than partially applied. It must be a single JSON object, and every member value must be a simple value (string, number,
true,falseornull) -- no Argon2 member takes an object or an array. Member names are matched exactly, and any member not listed below is an error rather than something ignored. A member given twice, or a member given together with its short alias, is also an error, because which one would win is ambiguous. All of this is deliberate. A misspelled name such asiteration, a miscapitalized one such asmemoryCostKB, or a single missing comma would otherwise be discarded in silence and the default used in its place. For a cost parameter that is a silent downgrade, and it produces a hash that looks perfectly valid, so nothing downstream would catch it. The specific problem is reported in theLastErrorText.variant-argon2id(the default),argon2i, orargon2d. Useargon2idunless there is a specific reason not to: it combines Argon2i's resistance to side-channel attacks with Argon2d's resistance to time-memory tradeoff attacks.version-19(the default, 0x13) or16(0x10). Only set16to reproduce a hash made by an old implementation.iterations- the number of passes over memory, calledtin RFC 9106. Must be at least 1. Defaults to3.memoryCostKb- the amount of memory used, in KB, calledmin RFC 9106. Must be at least 8 timesparallelism. Defaults to65536(64 MB). This is the parameter that does the most to make an attack expensive.parallelism- the number of lanes, calledpin RFC 9106. Defaults to1. Changing it changes the derived key. Chilkat computes all lanes on the calling thread, so raising it does not make the computation faster.keyLen- the length of the derived key in bytes. Must be between 4 and 1048576. Defaults to32.salt- the salt, which must be at least 8 bytes. 16 random bytes is the usual choice.secret- the optional secret valueKof RFC 9106, often called apepper: a key held by the application and not stored alongside the hash, so that a stolen database of hashes cannot be attacked without it.ad- the optional associated dataXof RFC 9106: additional non-secret data bound into the derivation.encoding- how thesalt,secretandadmembers are encoded. Defaults tobase64. May be any encoding Chilkat supports, such ashex, orutf-8to use the characters of the member itself as the bytes.saltEncoding,secretEncoding,adEncoding- overrideencodingfor one member.passwordCharset- the character encoding the password is converted to before use. Defaults toutf-8. If set tohexorbase64,passwordis instead treated as encoded binary and decoded, exactly as for the charset argument of.pbkdf2(String, String, String, String, int, int, String)maxMemoryKb- refuses to allocate more than this many KB. This is not an Argon2 parameter; it is a guard so that an unreasonablememoryCostKbcannot exhaust memory. Defaults to2097152(2 GB).
The short names used in RFC 9106 and in PHC hash strings are accepted as aliases:
tforiterations,mformemoryCostKb,pforparallelism, andvforversion. This means the parameters of an existing hash string such as$argon2id$v=19$m=65536,t=3,p=1$...can be transcribed directly.For example, to derive a 32-byte key:
{ "iterations": 3, "memoryCostKb": 65536, "parallelism": 1, "keyLen": 32, "salt": "cmFuZG9tc2FsdDEyMzQ=" }To hash a password for storage, use
instead, which generates a random salt and returns a self-describing string.argon2HashPassword(String, String)- Parameters:
password- thepasswordargument (notnull)json- thejsonargument (notnull)bdKey- thebdKeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
argon2HashPassword
Hashes a password using Argon2 (RFC 9106) and returns the result as a PHC format string, such as$argon2id$v=19$m=65536,t=3,p=1$c29tZXJhbmRvbXNhbHQ$3fJ7v1qKcVJ0lHqXjBQZ8mYm3sNTfSPRt0bqDl9kEyMThe string records the variant, version, memory cost, iterations, parallelism, salt and hash, so it is everything needed to verify the password later with
. Store the whole string.argon2VerifyPassword(String, String, String)passwordis the password.jsonis a JSON string containing the Argon2 options, which are the same members documented for, with one difference: the salt is optional here. As with all of the Argon2 methods, an unrecognized member name is an error. When noargon2DeriveKey(String, String, BinData)saltmember is present, a cryptographically random salt is generated for this hash, which is what should normally happen. AsaltLenmember (default16, allowed range 8 to 1024) sets how many random bytes to generate.Passing an empty string for
jsonuses all defaults: Argon2id, version 19, 3 iterations, 64 MB of memory, 1 lane, a 32-byte hash and a 16-byte random salt.Note that if a
secret(pepper) oradis used, it is not stored in the returned string. The same value must be supplied tofor the password to verify.argon2VerifyPassword(String, String, String)- Parameters:
password- thepasswordargument (notnull)json- thejsonargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
argon2VerifyPassword
Verifiespasswordagainst a PHC format Argon2 hash string previously produced by(or by any other RFC 9106 implementation).argon2HashPassword(String, String)Returns one of three values:
1- the password matched.0- the password did not match.-1- the verification could not be performed at all:phcHashwas not a valid Argon2 hash string, its parameters were out of range, or an internal failure occurred. The reason is written to theLastErrorText.
Test for a match with
== 1, never for!= 0, so that an unusable hash string is not mistaken for a successful login.The variant, version, memory cost, iterations, parallelism, salt and hash length are all read from
phcHash, so none of the Argon2 cost options need to be supplied. Pass an empty string forjsonunless the hash was created with asecret(pepper) orad, in which casejsonmust contain the same values that were used to create it. Only thesecret,ad,encoding,passwordCharsetandmaxMemoryKbmembers ofjsonare used; everything else is ignored. The other documented members are still accepted here, so that one JSON string can be shared between hashing and verifying, but an unrecognized member name is an error.A return of
0and a return of-1call for different handling.0is a normal failed login attempt.-1means the stored hash itself is unusable, which is a data or configuration problem rather than a bad password, and is worth logging or alerting on separately.The
maxMemoryKbmember is worth setting when the hash strings come from an untrusted source. The memory cost is taken fromphcHash, so a hash claiming an enormousmwould otherwise cause a very large allocation. It defaults to 2 GB and is checked before any memory is allocated.- Parameters:
password- thepasswordargument (notnull)json- thejsonargument (notnull)phcHash- thephcHashargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
bCryptHash
Computes and returns a bcrypt hash of thepassword. The number of rounds of hashing is determined by theBCryptWorkFactorproperty.Starting in v9.5.0.76, if the
passwordis prefixed with$2b$then the output will use the $2b version of bcrypt. For example, to create a$2b$bcrypt has for the passwordsecret, pass in the string$2b$secretforpassword.- Parameters:
password- thepasswordargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
bCryptVerify
Verifies thepasswordagainst a previously computed BCrypt hash. Returnstrueif the password matches thebcryptHash. Returnsfalseif the password does not match.- Parameters:
password- thepasswordargument (notnull)bcryptHash- thebcryptHashargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
ckDecryptFile
File-to-file decryption that supports files of any size by using internal streaming mode.- Parameters:
srcFile- thesrcFileargument (notnull)destFile- thedestFileargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
ckEncryptFile
Encrypts a file to another file using streaming mode, allowing files of virtually any size to be processed without loading the entire file into memory. The exception is when theCryptAlgorithmproperty is set to"pki", in which case the entire input file must reside in memory because public-key encryption is performed in-memory rather than as a streaming operation.- Parameters:
srcFile- thesrcFileargument (notnull)destFile- thedestFileargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
clearEncryptCerts
public void clearEncryptCerts()Clears the internal list of digital certificates to be used for public-key encryption. -
clearSigningCerts
public void clearSigningCerts()Clears the set of certificates to be used in signing. -
coSign
Co-sign's an existing CMS signature.bdIncontains the existing CMS signature. If successful,certis the output co-signed CMS signature.- Parameters:
bdIn- thebdInargument (notnull)cert- thecertargument (notnull)bdOut- thebdOutargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
crcBd
Computes a CRC for data contained incrcAlg, which can be eithercrc-32used in the Zip file format, orcrc8for the CRC8 algorithm.- Parameters:
crcAlg- thecrcAlgargument (notnull)bd- thebdargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
crcFile
Calculates the CRC for a file's contents using the CRC algorithm specified bycrcAlg. Possible algorithms are:crc-32- This is the CRC used in the Zip file format.crc8
- Parameters:
crcAlg- thecrcAlgargument (notnull)path- thepathargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
createP7M
Signs the contents ofinFilenameand writes the enveloping (i.e. opaque)PKCS7signature (.p7m) top7mPath.In a PKCS#7/CMS signature, the signer computes a cryptographic hash (e.g. SHA-256) of the data, then uses their private key to sign that hash.
The signature =
Sign( Hash(data) )This signed hash is what gets stored in the signature file. For enveloping/opaque signatures, the signed data is also stored in the signature file.
Set the
HashAlgorithmproperty to specify the hash algorithmg. The valid options aresha256,sha1,sha384, andsha512.- Parameters:
inFilename- theinFilenameargument (notnull)p7mPath- thep7mPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
createP7S
Signs the contents ofinFilenameand writes the detachedPKCS7signature (.p7s) top7sPath.In a PKCS#7/CMS detached signature, the signer computes a cryptographic hash (e.g. SHA-256) of the data, then uses their private key to sign that hash.
The signature =
Sign( Hash(data) )This signed hash is what gets stored in the signature file.
Set the
HashAlgorithmproperty to specify the hash algorithmg. The valid options aresha256,sha1,sha384, andsha512.- Parameters:
inFilename- theinFilenameargument (notnull)p7sPath- thep7sPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decodeString
Decodes from an encoding back to the original string. Theencodingcan be set to any of the following strings:base64,hex,quoted-printable,url,base32,Q,B,url_rc1738,url_rfc2396,url_rfc3986,url_oauth,uu,modBase64, orhtml(for HTML entity encoding).- Parameters:
inStr- theinStrargument (notnull)charset- thecharsetargument (notnull)encoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decryptBd
Decrypts the contents ofbd. This method can do eithersymmetric key decryptionorCMS public key decryption(e.g.,PKCS#7 EnvelopedData).Before calling this method for
symmetric key decryption(e.g.,AES,ChaCha20,Blowfish, etc.), ensure the following setup:- Define the encryption algorithm using the
CryptAlgorithmproperty. - Specify the encryption key length with the
KeyLengthproperty. - Establish the cipher mode through the
CipherModeproperty. - Use the
SetEncodedIVmethod to set the IV, if needed by the cipher mode. - Set the encryption key with the
SetEncodedKeymethod. - Ensure the
PaddingSchemeproperty matches the encryptor's value.
When calling this method for
public key decryption(i.e. decrypting aPKCS7 CMS message), the following setup is required:- The
CryptAlgorithmproperty should be set to the string"pki". - Optionally specify the certificate to be used for decryption by calling
SetDecryptCert. If SetDecryptCert is not called, then Chilkat will automatically search certificate sources (Windows certificate stores,Apple keychain, etc.) for the required certificate.
- Parameters:
bd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Define the encryption algorithm using the
-
decryptEncoded
Decrypts encoded encrypted data, and returns the decrypted data as a binary encoded string. For example:Input → Decode
EncodingMode→ Decrypt → EncodeEncodingMode→ OutputThe encoding (e.g.
base64,hex, etc.) is determined by theproperty.getEncodingMode()This method supports
symmetric keyandpublic keydecryption. For more information on properties that affect decryption, such as,getCryptAlgorithm(), etc., refer to thegetCipherMode()method documentation.decryptBd(BinData)- Parameters:
encodedEncryptedData- theencodedEncryptedDataargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decryptSb
This function is intended for use when the expected decrypted output is text. It decrypts the contents ofbdInand appends the resulting string tosbOut. Ensure that theproperty, such asgetCharset()utf-8,matches the one used during encryption to interpret the decrypted bytes correctly as characters.Input → Decrypt → Interpret Bytes according to
Charset→ Append to StringBuilderThis method supports
symmetric keyandpublic keydecryption. For more information on properties that affect decryption, such as,getCryptAlgorithm(), etc., refer to thegetCipherMode()method documentation.decryptBd(BinData)- Parameters:
bdIn- thebdInargument (notnull)sbOut- thesbOutargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decryptSecureENC
This function is intended for use when the expected decrypted output is text. It decrypts binary encoded encrypted bytes passed incipherTextand appends the resulting string tosecureStr. Ensure that theproperty, such asgetCharset()utf-8,matches the one used during encryption to interpret the decrypted bytes correctly as characters.Input → Decode using
EncodingMode→ Decrypt → Interpret Bytes according toCharset→ Append to Secure StringThe encoding (e.g.
base64,hex, etc.) is determined by theproperty.getEncodingMode()This method supports
symmetric keyandpublic keydecryption. For more information on properties that affect decryption, such as,getCryptAlgorithm(), etc., refer to thegetCipherMode()method documentation.decryptBd(BinData)- Parameters:
cipherText- thecipherTextargument (notnull)secureStr- thesecureStrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decryptStringENC
This function is intended for use when the expected decrypted output is text. It decrypts binary encoded encrypted bytes passed instrand appends the resulting string to ARG2. Ensure that theproperty, such asgetCharset()utf-8,matches the one used during encryption to interpret the decrypted bytes correctly as characters.Input → Decode using
EncodingMode→ Decrypt → Interpret Bytes according toCharset→ OutputThe encoding (e.g.
base64,hex, etc.) is determined by theproperty.getEncodingMode()This method supports
symmetric keyandpublic keydecryption. For more information on properties that affect decryption, such as,getCryptAlgorithm(), etc., refer to thegetCipherMode()method documentation.decryptBd(BinData)- Parameters:
str- thestrargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
encodeInt
Encodes an integer to N bytes and returns in the specified encoding. IflittleEndianistrue, thenlittle-endianbyte ordering is used. Otherwisebig-endianbyte order is used.- Parameters:
value- thevalueargumentnumBytes- thenumBytesargumentlittleEndian- thelittleEndianargumentencoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
encodeString
Binary encodes a string. ThetoEncodingNamecan be set to any of the binary encodings supported by Chilkat, such asbase64,hex, etc. (see the link below for the full list of encodings). ThecharsetName, such as"utf-8", determines the bytes that are encoded.The
toEncodingNamecan also be set to the valuehtmlfor HTML entity encoding.- Parameters:
strToEncode- thestrToEncodeargument (notnull)charsetName- thecharsetNameargument (notnull)toEncodingName- thetoEncodingNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
encryptBd
Encrypts the contents ofbd. This method can do eithersymmetric key encryptionorCMS public key encryption(e.g.,PKCS#7 EnvelopedData).Before calling this method for
symmetric key encryption(e.g.,AES,ChaCha20,Blowfish, etc.), ensure the following setup:- Define the encryption algorithm using the
property.getCryptAlgorithm() - Specify the encryption key length with the
property.getKeyLength() - Establish the cipher mode through the
property.getCipherMode() - Use the
method to set the IV, if needed by the cipher mode.setEncodedIV(String, String) - Set the encryption key with the
method.setEncodedKey(String, String) - Set the
property if needing something different than the default.getPaddingScheme()
When calling this method for
public key encryption(i.e. creating aPKCS7 CMS message), the following setup is required:- The
property should be set to the stringgetCryptAlgorithm()"pki". - To specify the encryption certificate, use
. For multiple certificates, callsetEncryptCert(Cert)for each one.addEncryptCert(Cert)
- Parameters:
bd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Define the encryption algorithm using the
-
encryptEncoded
Encrypts binary-encoded data and returns it as a binary-encoded string. For example:Input → Decode
EncodingMode→ Encrypt → EncodeEncodingMode→ OutputThe encoding (e.g.
base64,hex, etc.) is determined by theproperty.getEncodingMode()This method supports
symmetric keyandpublic keydecryption. For more information on properties that affect decryption, such as,getCryptAlgorithm(), etc., refer to thegetCipherMode()<a href="#DecryptBd"EncryptBdmethod documentation.- Parameters:
str- thestrargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
encryptSb
Encrypts text and appends the encrypted bytes inbdOut. Theproperty, such asgetCharset()utf-8, determines the actual bytes that are encrypted.StringBuilder→ Get bytes according toCharset→ Encrypt → Append toBinDataThis method supports
symmetric keyandpublic keyencryption. For more information on properties that affect encryption, such as,getCryptAlgorithm(), etc., refer to thegetCipherMode()method documentation.encryptBd(BinData)- Parameters:
sbIn- thesbInargument (notnull)bdOut- thebdOutargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
encryptSecureENC
Encrypts the secure string and returns the encrypted bytes as a binary encoded string. Theproperty determines the actual bytes that are encrypted.getCharset()SecureString→ Get bytes according toCharset→ Encrypt → Encode usingEncodingMode→ OutputThe encoding (e.g.
base64,hex, etc.) is determined by theproperty.getEncodingMode()This method supports
symmetric keyandpublic keyencryption. For more information on properties that affect encryption, such as,getCryptAlgorithm(), etc., refer to thegetCipherMode()method documentation.encryptBd(BinData)- Parameters:
secureStr- thesecureStrargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
encryptStringENC
Encrypts thestrand returns the encrypted bytes as a binary encoded string. Theproperty determines the actual bytes that are encrypted.getCharset()Input → Get bytes according to
Charset→ Encrypt → Encode usingEncodingMode→ OutputThe encoding (e.g.
base64,hex, etc.) is determined by theproperty.getEncodingMode()This method supports
symmetric keyandpublic keyencryption. For more information on properties that affect encryption, such as,getCryptAlgorithm(), etc., refer to thegetCipherMode()method documentation.encryptBd(BinData)- Parameters:
str- thestrargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
genRandomBytesENC
GeneratesnumBytesrandom bytes and returns them as an encoded string. The encoding format (e.g., base64, hex) is determined by theproperty. It utilizes thegetEncodingMode()Fortunacryptographically secure random number generator, auto-seeded by an OS-dependent secure entropy source.- Parameters:
numBytes- thenumBytesargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
generateUuid
Generates a random UUID string having standard UUID format, such asde305d54-75b4-431b-adb2-eb6b9e546014.Note: This generates a
version 4 UUIDusing random byte values. See RFC 4122.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getEncodedAuthTag
When encrypting inGCMmode, Chilkat generates theGCM authentication tag. The application can then use this method to retrieve the tag, which should be sent to the decrypting party along with the encrypted data. For further details on GCM authenticated encryption, please refer to the web pages linked below.- Parameters:
encoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getEncodedIV
This method retrieves the IV set by the application during the last call toorsetEncodedIV(String, String).randomizeIV()- Parameters:
encoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getLastJsonData
Offers details on the last method executed. While many methods provide no information, some do through GetLastJsonData. For instance, after invoking a signature verification method, GetLastJsonData will return JSON detailing the algorithms used.- Parameters:
json- thejsonargument (notnull)
-
getSignatureSigningTimeStr
This method retrieves the signing time of the Nth certificate in a digital signature after verification. The signing time for the first certificate is at index 0. Theproperty indicates the total number of signing certificates, although typically only one is used.getNumSignerCerts()Note: Before accessing the signing time, use the
method to verify its availability, and skip indices lacking a signing time. The signing time is returned inhasSignatureSigningTime(int)RFC822 string format.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getSignedAttributes
Extracts the signed (authenticated) attributes for the Nth signer, wheresignerIndexis typically 0, as most signatures have only one signer.Provide the binary PKCS7 in
pkcs7Der. If successful,sbJsonwill hold the signed attributes in JSON format.Sample JSON output:
{ "signedAttributes": [ { "oid": "1.2.840.113549.1.9.3", "name": "Content Type" }, { "oid": "1.2.840.113549.1.9.5", "name": "Signing Time" }, { "oid": "1.2.840.113549.1.9.4" "name": "Message Digest" }, { "oid": "1.2.840.113549.1.9.16.2.47", "name": "Signing Certificate V2" } ] }- Parameters:
signerIndex- thesignerIndexargumentpkcs7Der- thepkcs7Derargument (notnull)sbJson- thesbJsonargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
hasSignatureSigningTime
public boolean hasSignatureSigningTime(int index)After verifying a digital signature with a signature verification method, you can call this method. It returnstrueif the signing time for the Nth certificate is available and can be accessed using themethod.getSignatureSigningTimeStr(int)- Parameters:
index- theindexargument- Returns:
- the result; this method never throws
ChilkatException
-
hashBdENC
Hashes the bytes inbdand returns the hash as a binary-encoded string. The hash algorithm is determined by theproperty, while the encoding is specified by thegetHashAlgorithm()property. Encoding options includegetEncodingMode()base64,hex,base64url, or others listed at the link below.- Parameters:
bd- thebdargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hashBeginString
To hash a large amount of text, start by processing the first chunk using this method. For subsequent chunks, use themethod as needed. Conclude by callinghashMoreString(String)to obtain the final result. The hash algorithm is determined by thehashFinalENC()property setting.getHashAlgorithm()- Parameters:
strData- thestrDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hashChunkBd
Start or continue hashing data in chunks. SetfirstChunktotruefor the first chunk, andfalsefor subsequent chunks. Finish by callingHashFinalENCto obtain the result. The hash algorithm used is determined by theHashAlgorithmproperty.- Parameters:
firstChunk- thefirstChunkargumentbd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hashFileENC
Hashes a file and returns the hash as an encoded string.The hash algorithm is specified by the
HashAlgorithmproperty, The encoding is controlled by theEncodingModeproperty, which can be set tobase64,hex,base64url, or any of the encodings listed at the link below.Any size file is supported because the file is hashed internally in streaming mode (keeping memory usage low and constant).
- Parameters:
path- thepathargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hashFinalENC
Finalizes a multi-step hash computation and returns the hash bytes encoded according to theproperty setting.getEncodingMode()- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hashMoreString
Adds more text to the hash currently under computation. (See)hashBeginString(String)- Parameters:
strData- thestrDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hashStringENC
Hashes thestrand returns the hash as a binary encoded string. Theproperty determines the actual bytes that are hashed.getCharset()Input → Get bytes according to
Charset→ Hash → Encode usingEncodingMode→ OutputThe encoding (e.g.
base64,hex, etc.) is determined by theproperty.getEncodingMode()The hash algorithm is determined by the
property.getHashAlgorithm()- Parameters:
str- thestrargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hotp
public String hotp(String secret, String secretEnc, String counterHex, int numDigits, int truncOffset, String hashAlg)Implements RFC 4226: HOTP: An HMAC-Based One-Time Password Algorithm. The arguments to this method are:secret: The shared secret in an enocded representation such as base64, hex, ascii, etc.secretEnc: The encoding of the shared secret, such asbase64counterHex: The 8-byte counter in hexidecimal format.numDigits: The number of decimal digits to return.truncOffset: Normally set this to -1 for dynamic truncation. Otherwise can be set in the range 0..15.hashAlg: Normally set tosha1. Can be set to other hash algorithms such assha256,sha512, etc.
- Parameters:
secret- thesecretargument (notnull)secretEnc- thesecretEncargument (notnull)counterHex- thecounterHexargument (notnull)numDigits- thenumDigitsargumenttruncOffset- thetruncOffsetargumenthashAlg- thehashAlgargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
lastDecryptCert
Returns incertthe last certificate used for public-key decryption.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
lastSignerCert
Retrieves the Nth certificate used for signing incert, where the first certificate is at index 0. Use this method after verifying a digital signature to access the signer certificates. Theproperty indicates the total number of signing certificates. Usually, only one certificate is used when creating a digital signature.getNumSignerCerts()- Parameters:
index- theindexargumentcert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
macBdENC
Generates a Message Authentication Code (MAC) for the bytes inbdusing the algorithm defined by theproperty. The resulting MAC is encoded into a string based on thegetMacAlgorithm()property (e.g.,getEncodingMode()base64orhex). Theproperty determines the internal hash function. Before generating the MAC, specify the secret key usinggetHashAlgorithm().setMacKeyEncoded(String, String)- Parameters:
bd- thebdargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
macStringENC
Computes a Message Authentication Code (MAC) and returns it as a binary encoded string. The MAC algorithm is defined by theproperty. ThegetMacAlgorithm()property determines the actual bytes that are hashed.getCharset()Input → Get bytes according to
Charset→ MAC → Encode usingEncodingMode→ OutputThe encoding (e.g.
base64,hex, etc.) is determined by theproperty.getEncodingMode()The hash algorithm is determined by the
property. The secret key must be set beforehand by callinggetHashAlgorithm().setMacKeyEncoded(String, String)- Parameters:
inText- theinTextargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
mySqlAesDecrypt
MatchesMySQL'sAES_DECRYPTfunction.strEncryptedHexis a hex-encoded AES-encrypted string, and the return value is the original unencrypted string.- Parameters:
strEncryptedHex- thestrEncryptedHexargument (notnull)strPassword- thestrPasswordargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
mySqlAesEncrypt
This function replicatesMySQL'sAES_ENCRYPT, returning the encrypted data as a hex-encoded string. In MySQL, this is done using:HEX(AES_ENCRYPT('The quick brown fox jumps over the lazy dog', 'password')).- Parameters:
strData- thestrDataargument (notnull)strPassword- thestrPasswordargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
opaqueSignBd
Digitally signs the contents ofbd. If successful, the contents ofbdare replaced with thePKCS#7 signed-data, which embeds the original data within the signature. Ensure a certificate is set usingbefore invoking this method. ThesetSigningCert(Cert)property specifies the hash algorithm for creating the data's hash during signing.getHashAlgorithm()- Parameters:
bd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
opaqueSignStringENC
Digitally signs a string and returnsPKCS#7 signed-dataas abinary encoded string. Theproperty determines the binary encoding, such asgetEncodingMode()base64,hex,hex_lower,base64_mime, etc. Theproperty determines the actual bytes that are hashed and signed. ThegetCharset()property specifies the hash algorithm for creating the data's hash during signing.getHashAlgorithm()- Parameters:
str- thestrargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
opaqueVerifyBd
The method performs in-place verification of thePKCS#7 signed-datacontent ofbd. If the signature is successfully verified, the content ofbdis replaced with the original data, and the method returnstrue. If verification fails,bdremains unchanged, and the method returnsfalse. Afterwards, you can retrieve signer certificates by using theproperty and thegetNumSignerCerts()method.lastSignerCert(int, Cert)- Parameters:
bd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
opaqueVerifyStringENC
This function verifies aPKCS#7 signed-databinary-encoded signature and returns the original text data. Theproperty determines howgetEncodingMode()p7mis decoded to bytes. If the signature does not verify successfully, it returns an empty string. Theproperty specifies how the original data bytes are converted to characters. You can obtain signer certificates using thegetCharset()property and thegetNumSignerCerts()method.lastSignerCert(int, Cert)- Parameters:
p7m- thep7margument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
pbkdf1
public String pbkdf1(String password, String charset, String hashAlg, String salt, int iterationCount, int outputKeyBitLen, String encoding)This function implements thePBKDF1(Password-Based Key Derivation Function #1) algorithm. Follow these guidelines to use it:-
password(the password) is first converted using the character encoding specified bycharsetbefore being processed by the key derivation function. -
hashAlgspecifies the hash function to use, such asmd5,sha1, ormd2. -
saltrepresents the salt, which should be random data of at least 8 bytes (64 bits). You can use themethod to generate this.genRandomBytesENC(int) -
iterationCountsets the iteration count, which must be a minimum of 1000. -
outputKeyBitLendetermines the length (in bits) of the derived key. -
encodingdefines the output encoding format, such asbase64orhex, and also the expected encoding ofsalt(the salt).
The function returns the derived key.
Note: If
charsetis specified as hex or base64, the password (password) will be treated as binary data encoded in that format. It will be decoded into binary form and used directly as such.- Parameters:
password- thepasswordargument (notnull)charset- thecharsetargument (notnull)hashAlg- thehashAlgargument (notnull)salt- thesaltargument (notnull)iterationCount- theiterationCountargumentoutputKeyBitLen- theoutputKeyBitLenargumentencoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
-
pbkdf2
public String pbkdf2(String password, String charset, String hashAlg, String salt, int iterationCount, int outputKeyBitLen, String encoding)Implements thePBKDF2algorithm as follows:- Convert
passwordto the character encoding specified bycharsetbefore using it in the key derivation function. hashAlgspecifies the hash algorithm. Options includesha256,sha384,sha512,md5,sha1,md2, or any algorithm listed in the HashAlgorithm property.- Provide a random
saltvalue that is at least 8 bytes (64 bits) long. Use methods liketo generate this salt value.genRandomBytesENC(int) - Ensure
iterationCountis 1000 or greater. - Control the length of the derived key output using
outputKeyBitLen. - Set
encodingto specify the encoding format for the output and the expected encoding forsalt. Options includebase64andhex.
The derived key is the output of this process. Internally, PBKDF2 uses a pseudorandom function (PRF), specifically a keyed HMAC. The hash algorithm chosen with
hashAlgdictates this PRF; for example,SHA256uses HMAC-SHA256, whileSHA1uses HMAC-SHA1.Note: If
charsetishexorbase64,passwordis treated as binary data. It will be decoded and used directly as a binary password.SHA256uses HMAC-SHA256, whileSHA1uses HMAC-SHA1.PBKDF1 and PBKDF2 are both key derivation functions used to strengthen passwords for cryptographic purposes, but PBKDF2 is the improved version.
- PBKDF1: Older and limited - it can only generate small keys (up to the hash function’s output size), making it less flexible and secure.
- PBKDF2: More advanced - it can generate longer keys, is more resistant to
attacks, and is widely recommended for modern security needs.
In short,
PBKDF2is stronger and more versatile thanPBKDF1.- Parameters:
password- thepasswordargument (notnull)charset- thecharsetargument (notnull)hashAlg- thehashAlgargument (notnull)salt- thesaltargument (notnull)iterationCount- theiterationCountargumentoutputKeyBitLen- theoutputKeyBitLenargumentencoding- theencodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Convert
-
randomizeIV
public void randomizeIV()Sets the initialization vector (IV) to a random value. Theproperty should be set prior to calling this method.getCryptAlgorithm()A random IV is used in symmetric encryption (like AES-CBC or AES-GCM) to ensure that encrypting the same plaintext with the same key produces different ciphertext each time. This prevents attackers from recognizing patterns in encrypted data and strengthens security.
Why use a random IV?
- It ensures semantic security (i.e. same plaintext never results in same ciphertext).
- Prevents replay and pattern attacks.
- Especially important in modes like CBC and GCM.
How is the IV sent to the decrypting party?
The IV is not secret, but it must be available for decryption. Common methods:
- Prepended to the ciphertext (e.g.,
IV || ciphertext) - Sent in a separate field (e.g., JSON field, HTTP header)
- Concatenated and encoded (e.g., base64 of IV + ciphertext)
At the receiving side, the decryptor extracts the IV and uses it with the shared key to decrypt the ciphertext correctly.
-
reEncode
This method converts between different encodings, such as frombase64tohex. Each argument can be any binary encoding supported by Chilkat.- Parameters:
encodedData- theencodedDataargument (notnull)fromEncoding- thefromEncodingargument (notnull)toEncoding- thetoEncodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setDecryptCert
Sets the digital certificate for decryption when theproperty is set togetCryptAlgorithm()"pki". This method requires that the certificate has a private key.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setDecryptCert2
Sets the digital certificate and associated private key for decryption when theproperty is set togetCryptAlgorithm()"pki". The private key must be the one that matches the certificate's public key.- Parameters:
cert- thecertargument (notnull)key- thekeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setEncodedAad
Sets the optional authenticated additional data (AAD) for AES encryption inGCMmode. The data is provided as a binary-encoded string using the specifiedencoding, and any binary encoding supported by Chilkat can be used.In GCM (Galois/Counter Mode) encryption, AAD (Additional Authenticated Data) is optional input that is not encrypted but is authenticated along with the ciphertext. It's used to verify integrity of associated data like headers or metadata. If AAD is modified, decryption will fail due to authentication tag mismatch.
- Parameters:
aadStr- theaadStrargument (notnull)encoding- theencodingargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setEncodedAuthTag
In GCM mode, the authentication tag is a short value (e.g. 16 bytes) generated during encryption that ensures the integrity and authenticity of both the ciphertext and any AAD. It must be verified during decryption to confirm the data hasn't been altered.When decrypting AES-GCM, applications must call this method to provide the expected authentication tag.
To prevent Chilkat from checking the authentication tag after decryption, you can set the authentication tag to the special
hexvalueFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF(16 bytes of 0xFF).- Parameters:
authTagStr- theauthTagStrargument (notnull)encoding- theencodingargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setEncodedIV
Sets the initialization vector used in symmetric encrpytion (AES,Blowfish, etc.) from a binary-encoded string using any Chilkat-supported encoding method (e.g.,base64,hex).An Initialization Vector (IV) is a random or unique value used in symmetric encryption to ensure that encrypting the same plaintext multiple times produces different ciphertexts. It prevents pattern leakage.
Cipher Modes That Require an IV:
CBC(Cipher Block Chaining)CFB(Cipher Feedback)OFB(Output Feedback)CTR(Counter Mode)GCM(Galois/Counter Mode)
ECB (Electronic Codebook) does *not* use an IV, which makes it less secure.
- Parameters:
ivStr- theivStrargument (notnull)encoding- theencodingargument (notnull)
-
setEncodedKey
Sets the encryption key used in symmetric encryption (AES,Blowfish, etc.) from a binary-encoded string using any Chilkat-supported encoding method (e.g.,base64,hex).The key must have a byte size equal to the
property. For instance, a KeyLength ofgetKeyLength()128 bitsrequires a16-bytekey, and a KeyLength of256 bitsrequires a32-bytekey.- Parameters:
keyStr- thekeyStrargument (notnull)encoding- theencodingargument (notnull)
-
setEncodedSalt
Sets thepbes2orpbes1salt bytes from a binary-encoded string using any Chilkat-supported encoding method (e.g.,base64,hex).This salt is used for encryption and decryption when the
property is set togetCryptAlgorithm()pbes1orpbes2. Note: This does not apply to theorpbkdf1(String, String, String, String, int, int, String)methods, where the salt is provided as a function argument.pbkdf2(String, String, String, String, int, int, String)- Parameters:
saltStr- thesaltStrargument (notnull)encoding- theencodingargument (notnull)
-
setEncryptCert
Instructs the encryption library to use a specified digital certificate for public-key encryption. To encrypt using multiple certificates, callfor each one. This action is equivalent to callingaddEncryptCert(Cert)beforeclearEncryptCerts().addEncryptCert(Cert)- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setMacKeyEncoded
Sets the MAC key from a binary-encoded string using any Chilkat-supported encoding method (e.g.,base64,hex).- Parameters:
key- thekeyargument (notnull)encoding- theencodingargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setMacKeyString
Sets the MAC key from a string. Theproperty determines the actual bytes used for the MAC key.getCharset()- Parameters:
key- thekeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setSigningCert
Sets the digital certificate to be used for signing. Signing requires that the certificate has a private key.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setSigningCert2
Sets the digital certificate and associated private key for signing. The private key must be the one that matches the certificate's public key.- Parameters:
cert- thecertargument (notnull)privateKey- theprivateKeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setTsaHttpObj
If timestamp server communications are needed for signing and special Internet settings like a proxy server are necessary, this method can provide an Http object configured with these settings.- Parameters:
http- thehttpargument (notnull)
-
setVerifyCert
Assigns the digital certificate for signature verification. Typically, a PKCS7 (CMS) signature includes the signing certificate information, making it unnecessary to call this method explicitly. This is only required in rare instances.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
signBdENC
Digitally signs the content indataToSignand returns adetachedsignature (PKCS#7 signed-data) as a binary-encoded string. Theproperty determines the binary-encoding. Possible encodings includegetEncodingMode()base64,base64_mime,hex, andhex_lower. Theproperty specifies the hash algorithm for creating the data's hash during signing.getHashAlgorithm()- Parameters:
dataToSign- thedataToSignargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
signHashENC
Digitally signs a pre-computed hash and returns adetachedsignature (PKCS#7 signed-data) as a binary-encoded string. Theproperty determines the binary-encoding. Possible encodings includegetEncodingMode()base64,base64_mime,hex, andhex_lowerencodedHashis a binary-encoded hash to be signed, with its encoding format specified byhashEncoding(e.g.,base64,hex).hashAlgspecifies the hash algorithm (e.g.,sha256,sha1,sha512) used forencodedHash.- Parameters:
encodedHash- theencodedHashargument (notnull)hashAlg- thehashAlgargument (notnull)hashEncoding- thehashEncodingargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
signSbENC
Digitally signs the text contained insband returns adetachedsignature (PKCS#7 signed-data) as a binary-encoded string. Theproperty determines the binary-encoding. Possible encodings includegetEncodingMode()base64,base64_mime,hex, andhex_lower. Theproperty specifies the hash algorithm for creating the data's hash during signing. ThegetHashAlgorithm()property determines the actual bytes that are hashed and signed.getCharset()- Parameters:
sb- thesbargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
signStringENC
Digitally signs a string and returns adetachedsignature (PKCS#7 signed-data) as a binary-encoded string. Theproperty determines the binary-encoding. Possible encodings includegetEncodingMode()base64,base64_mime,hex, andhex_lower. Theproperty specifies the hash algorithm for creating the data's hash during signing. ThegetHashAlgorithm()property determines the actual bytes that are hashed and signed.getCharset()- Parameters:
str- thestrargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
totp
public String totp(String secret, String secretEnc, String t0, String tNow, int tStep, int numDigits, int truncOffset, String hashAlg)Implements RFC 6238: TOTP: Time-Based One-Time Password Algorithm. The arguments to this method are:secret: The shared secret in an enocded representation such as base64, hex, ascii, etc.secretEnc: The encoding of the shared secret, such asbase64t0: The Unix time to start counting time steps. It is a number in decimal string form. A Unix time is the number of seconds elapsed since midnight UTC of January 1, 1970.0is a typical value used for this argument.tNow: The current Unix time in decimal string form. To use the current system date/time, pass an empty string for this argument.tStep: The time step in seconds. A typical value is 30. Note: Both client and server must pre-agree on the secret, the t0, and the tStep.numDigits: The number of decimal digits to return.truncOffset: Normally set this to -1 for dynamic truncation. Otherwise can be set in the range 0..15.hashAlg: Normally set tosha1. Can be set to other hash algorithms such assha256,sha512, etc.
- Parameters:
secret- thesecretargument (notnull)secretEnc- thesecretEncargument (notnull)t0- thet0argument (notnull)tNow- thetNowargument (notnull)tStep- thetStepargumentnumDigits- thenumDigitsargumenttruncOffset- thetruncOffsetargumenthashAlg- thehashAlgargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
useCertVault
Adds an XML certificate vault to the object's internal list of sources to be searched for certificates and private keys when encrypting/decrypting or signing/verifying. Unlike the AddPfxSourceData and AddPfxSourceFile methods, only a single XML certificate vault can be used. If UseCertVault is called multiple times, only the last certificate vault will be used, as each call to UseCertVault will replace the certificate vault provided in previous calls.- Parameters:
vault- thevaultargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
verifyBdENC
Verifies adetached digital signatureagainst the original data contained indata. Returnstrueif the signature is verified. TheencodedSigholds a binary-encodedPKCS#7 signed-datadetached signature. The type of binary encoding, such asbase64,hex,orbase64_mime,is determined by theproperty.getEncodingMode()Afterwards, you can retrieve signer certificates by using the
property and thegetNumSignerCerts()method.lastSignerCert(int, Cert)- Parameters:
data- thedataargument (notnull)encodedSig- theencodedSigargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
verifyP7M
Verifies anopaque digital signaturecontained in a.p7mfile and extracts the original data todestPath. Returnstrueif the .p7m is validated and the original data was extracted. Otherwise returnsfalse.Afterwards, you can retrieve signer certificates by using the
property and thegetNumSignerCerts()method.lastSignerCert(int, Cert)- Parameters:
p7mPath- thep7mPathargument (notnull)destPath- thedestPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
verifyP7S
Verifies adetached digital signaturecontained in a.p7sfile against the original data contained inoriginalDataPath. Returnstrueif the signature is verified.Afterwards, you can retrieve signer certificates by using the
property and thegetNumSignerCerts()method.lastSignerCert(int, Cert)- Parameters:
originalDataPath- theoriginalDataPathargument (notnull)p7sPath- thep7sPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
verifySbENC
Verifies adetached digital signatureagainst the original text contained insb. Returnstrueif the signature is verified. TheencodedSigholds a binary-encodedPKCS#7 signed-datadetached signature. The type of binary encoding, such asbase64,hex,orbase64_mime,is determined by theproperty. ThegetEncodingMode()property determines how the text ingetCharset()sbis converted to bytes for signature validation.Afterwards, you can retrieve signer certificates by using the
property and thegetNumSignerCerts()method.lastSignerCert(int, Cert)- Parameters:
sb- thesbargument (notnull)encodedSig- theencodedSigargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
verifyStringENC
Verifies adetached digital signatureagainst the original text instr. Returnstrueif the signature is verified. TheencodedSigholds a binary-encodedPKCS#7 signed-datadetached signature. The type of binary encoding, such asbase64,hex,orbase64_mime,is determined by theproperty. ThegetEncodingMode()property determines how the text ingetCharset()stris converted to bytes for signature validation.Afterwards, you can retrieve signer certificates by using the
property and thegetNumSignerCerts()method.lastSignerCert(int, Cert)- Parameters:
str- thestrargument (notnull)encodedSig- theencodedSigargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
xtsSetDataUnitNumber
public void xtsSetDataUnitNumber(long loUint32, long hiUint32)Sets the XTS-AES mode data unit number. The data unit number is a 64-bit unsigned integer. It is passed in as two 32-bit unsigned integers representing the high and low 32-bits.Setting the data unit number is one way of setting the tweak value. The tweak value is 16 bytes in length and can alternatively be set by calling XtsSetEncodedTweakValue.
This method sets the tweak value such that the first 8 bytes are composed of the little-endian 64-bit data unit number, followed by 8 zero bytes.
(Unfortunately, Chilkat cannot use 64-bit integers in method arguments because many older programming environments, such as ActiveX, do not support it. Chilkat must present an identical and uniform API across all programming languages.)
- Parameters:
loUint32- theloUint32argument (0 .. 4294967295)hiUint32- thehiUint32argument (0 .. 4294967295)
-
xtsSetEncodedTweakKey
Sets the XTS-AES mode tweak key from an encoded string. The encoding argument can be set to any of the following strings:base64,hex,quoted-printable,ascii, orurl. The tweak key should be equal in size to the encryption key. For example, to do 256-bit AES-XTS, the encryption key is 256-bits, and the tweak key is also 256-bits.- Parameters:
key- thekeyargument (notnull)encoding- theencodingargument (notnull)
-
xtsSetEncodedTweakValue
Sets the XTS-AES mode tweak value from an encoded string. The encoding argument can be set to any of the following strings:base64,hex,quoted-printable,ascii, orurl.The tweak value must be 16 bytes in length. An application can set the initial tweak value by calling this method, or by calling XtsSetDataUnitNumber (but not both).
- Parameters:
tweak- thetweakargument (notnull)encoding- theencodingargument (notnull)
-
setProgressListener
Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.- Parameters:
listener- the listener, ornull- Throws:
IllegalStateException- if called from inside one of this object's own callbacks
-
getProgressListener
Returns the installed listener, ornull.- Returns:
- the listener installed with
setProgressListener(ProgressListener)or one of theon...methods
-
onAbortCheck
Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onPercentDone
Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onProgressInfo
Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-