Note for Windows users: If you have trouble running the
npm run bundle command, try this instead:

node node_modules\requirejs\bin\r.js -o minify.js

This will create a single minimized file that can be included in
the browser:

js/forge.min.js

Include the file via:

<scriptsrc="js/forge.min.js"></script>

Note that the minify script depends on the requirejs package,
and that the requirejs binary 'r.js' assumes that the name of
the node binary is 'node' not 'nodejs', as it is on some
systems. You may need to change the hashbang line to use
'nodejs' or run the command manually.

To create a single non-minimized file that can be included in
the browser:

npm install

npm run bundle

Note for Windows users: If you have trouble running the
npm run bundle command, try this instead:

Any contributions (eg: PRs) that are accepted will be brought under the same
license used by the rest of the Forge project. This license allows Forge to
be used under the terms of either the BSD License or the GNU General Public
License (GPL) Version 2.

If at any time you wish to disable the use of native code, where available,
for particular forge features like its secure random number generator, you
may set the disableNativeCode flag on forge to true. It
is not recommended that you set this flag as native code is typically more
performant and may have stronger security properties. It may be useful to
set this flag to test certain features that you plan to run in environments
that are different from your testing environment.

When using an AES algorithm, the key size will determine whether
AES-128, AES-192, or AES-256 is used (all are supported). When a DES
algorithm is used, the key size will determine whether 3DES or regular
DES is used. Use a 3DES algorithm to enforce Triple-DES.

// pass is false if there was a failure (eg: authentication tag didn't match)

if(pass){

// outputs decrypted hex

console.log(decipher.output.toHex());

}

Using forge in node.js to match openssl's "enc" command line tool (Note: OpenSSL "enc" uses a non-standard file format with a custom key derivation function and a fixed iteration count of 1, which some consider less secure than alternatives such as OpenPGP/GnuPG):

Note for Chrome/Firefox/iOS/similar users: If you have trouble importing
a PKCS#12 container, try using the TripleDES algorithm. It can be passed
to forge.pkcs12.toPkcs12Asn1 using the {algorithm: '3des'} option.

Provides a Fortuna-based cryptographically-secure pseudo-random number
generator, to be used with a cryptographic function backend, e.g. AES. An
implementation using AES as a backend is provided. An API for collecting
entropy is given, though if window.crypto.getRandomValues is available, it will
be used automatically.

Examples

// get some random bytes synchronously

var bytes =forge.random.getBytesSync(32);

console.log(forge.util.bytesToHex(bytes));

// get some random bytes asynchronously

forge.random.getBytes(32,function(err,bytes){

console.log(forge.util.bytesToHex(bytes));

});

// collect some entropy if you'd like

forge.random.collect(someRandomBytes);

jQuery().mousemove(function(e){

forge.random.collectInt(e.clientX,16);

forge.random.collectInt(e.clientY,16);

});

// specify a seed file for use with the synchronous API if you'd like

forge.random.seedFileSync=function(needed){

// get 'needed' number of random bytes from somewhere

return fetchedRandomBytes;

};

// specify a seed file for use with the asynchronous API if you'd like

forge.random.seedFile=function(needed,callback){

// get the 'needed' number of random bytes from somewhere

callback(null, fetchedRandomBytes);

});

// register the main thread to send entropy or a Web Worker to receive

Provides an Apache module "mod_fsp" that can serve up a Flash Socket
Policy. See mod_fsp/README for more details. This module makes it easy to
modify an Apache server to allow cross domain requests to be made to it.