You are here: Reference > JavaScript > client-side > browser > objects > crypto

crypto object

Browser support:
Represents the security object of the Firefox browser. The crypto object allows access to various browser security and cryptographic features.

Syntax:

Properties that reference the object:
window.crypto
The base interface, through which you can add new functionalities to the crypto object, is the Crypto interface.

Possible members:

Properties:
enableSmartCardEvents
Sets or retrieves a Boolean value that indicates whether the document recieves SmartCard events.

This property is read/write.
version
Returns a string that specifies the version number of the crypto object.

This property is read-only.
Methods:
alert (message)
3.5
Displays an alert window with the specified message and an OK button. The support for this method has been removed in Firefox 3.5.

Parameters:

message
Required. String that specifies the message to display.

Return value:

This method has no return value.
disableRightClick ( )
Disables the right mouse click. Not Implemented yet.

Return value:

This method has no return value.
generateCRMFRequest (requestedDN, regToken, authenticator, escrowAuthorityCert, doneCode, keySize1, keyParams1, keyGenAlg1 [, ...[, keySizeN, keyParamsN, keyGenAlgN]])
Generates a CRMF (Certificate Request Message Format) request.
For detailed information, please visit this site: GenerateCRMFRequest method (Mozilla Developer Center)

Return value:

Returns a CRMF Request object.
importUserCertificates (nickname, cmmfResponse, forceToBackUp)
Imports a certificate for the user.
For detailed information, please visit this site: importUserCertificates method (Mozilla Developer Center)

Parameters:

nickname
Required. String that specifies a description about the certificate.
cmmfResponse
Required. A base-64 encoded string that specifies CMMF (Certificate Request Message Format) Response from the CA (Certification Authority).
forceToBackUp
Required. Boolean value that indicates whether the user should be prompted to back up the key.

Return value:

Returns an empty string on success, else returns a string that specifies the error message.
logout ( )
Logs the user out.

Return value:

This method has no return value.
popChallengeResponse (challenge)
For detailed information, please visit this site: PopChallengeResponse method (Mozilla Developer Center)

Parameters:

challenge
Required. String that specifies a base-64 encoded challenge message.

Return value:

Returns a string that identifies the base-64 encoded response string or an error message if fails.
random (numBytes)
Generates a random number. Not implemented yet.

Parameters:

numBytes
Required. Integer that specifies the count of bytes used by the cryptographic engine. Must be between 1 and 10.

Return value:

Returns the generated number.

Example HTML code 1:

This example illustrates the use of the crypto object:
<head>
    <script type="text/javascript">
        function Notify () {
            if (window.crypto) {
                crypto.alert ("The operation was successful!");
            }
            else {
                alert ("Your browser does not support the crypto object!");
            }
        }
   </script>
</head>
<body>
    <button onclick="Notify ()">Create an alert window</button>
</body>
Did you find this example helpful? yes no

External links:

User Contributed Comments

Post Content

Post Content