travist/jsencrypt — pull request #29 by jrrbru (2014-08-16 13:22:46+00:00)
Title: Support RSA signing with custom padding

As part of an effort to use this library to do signature generation and verification, I added two new internal methods to jsencrypt.js:

RSASign(text, hashMethod, padMethod)
RSAVerify(signature, text, hashMethod, unPadMethod)

These are exposed via JSEncrypt.sign(...) and JSEncrypt.verify(...). These two methods allow you to sign and verify text, while supplying your own hashMethod and padMethod. This allows you to support any hash method and padding scheme for interoperability with server-side code:

```javascript
// Create the encryption object.
crypt = new JSEncrypt();

// Set the public key
crypt.setPublicKey('-----BEGIN PUBLIC KEY-----.....-----END PUBLIC KEY-----');

// verify the signature
if (crypt.verify(signature, terms_string, Hashes.SHA256.hex, myUnPaddingMethod)) {
// do stuff here
}
```

Also included are a few JSDoc changes that more accurately reflect the types returned from various functions (like changing @returns {string} to @returns {string|boolean} when one possible execution path returns false).