Skip to content
Simple Free RSA / AES Encryption and Decryption
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
test
.gitignore
.npmignore
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

simple-free-encryption-tool

Simple Free RSA / AES Encryption and Decryption

Simple Free Encryption Tool (sfet) uses RSA and AES versions that are strong and allow encryption between client-side Javascript, Node.js and C#.

Open and free for all to see, can be run stand-alone on a local machine for an extra sense of security; all functionality runs entirely locally once the page has been loaded. Latest client version be loaded directly from the GitHub repo here.

Installation

npm install simple-free-encryption-tool

Testing and Building

npm test
npm run build

Client

<script src="js/windowSfet.js"></script>

<script language="javascript">
        // Call this code when the page is done loading.
        $(function () {
            alert('"secret md5 message" hashed: ' + sfet.md5.hash('secret md5 message'));

            // asynchronous not available in browser, can be implemented using HTML5 Worker class
            var keys = sfet.rsa.generateKeysSync();
            alert('loaded in ' + keys.time);

            var encrypted = sfet.rsa.encrypt(keys.public, "secret rsa message");
            var decrypted = sfet.rsa.decrypt(keys.private, encrypted);
            alert('rsa decrypted ' + decrypted);
            
            encrypted = sfet.aes.encrypt('secret', 'secret aes message')
            decrypted = sfet.aes.decrypt('secret', encrypted);
            alert('aes decrypted ' + decrypted);
        });
    </script>
    </script>
</head>

Server

const sfet = require('simple-free-encryption-tool');

// (key size defaults to 2048 if null)
var keySize = 2048;

// generateKeys() runs key generation in a separate child process
sfet.rsa.generateKeys(keySize, (error, keys) => {
    console.log(keys.keySize + '-bit key pair generated asynchronously in ' + keys.time + 'ms');
});

var keys = sfet.rsa.generateKeysSync(keySize);
console.log(keys.keySize + '-bit key pair generated synchronously in ' + keys.time + 'ms');

var encrypted = sfet.rsa.encrypt(keys.public, "secret rsa message");
var decrypted = sfet.rsa.decrypt(keys.private, encrypted);
console.log('rsa decrypted ' + decrypted);

encrypted = sfet.aes.encrypt('secret', 'secret aes message')
decrypted = sfet.aes.decrypt('secret', encrypted);
console.log('aes decrypted ' + decrypted);

C# compatibility

C# counterparts available here:

You can’t perform that action at this time.