Skip to content

Commit

Permalink
fix browser compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
rzcoder committed Apr 20, 2014
1 parent 622938e commit fe203d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-rsa",
"version": "0.1.40",
"version": "0.1.41",
"description": "Node.js RSA library",
"main": "src/NodeRSA.js",
"scripts": {
Expand Down
10 changes: 8 additions & 2 deletions src/NodeRSA.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ module.exports = (function() {
* @param publicPEM {string}
*/
NodeRSA.prototype.loadFromPrivatePEM = function(privatePEM, encoding) {
var pem = privatePEM.replace('-----BEGIN RSA PRIVATE KEY-----','').replace('-----END RSA PRIVATE KEY-----','');
var pem = privatePEM
.replace('-----BEGIN RSA PRIVATE KEY-----','')
.replace('-----END RSA PRIVATE KEY-----','')
.replace(/\s+|\n|\r$/gm, '');
var reader = new ber.Reader(new Buffer(pem, 'base64'));

reader.readSequence();
Expand All @@ -96,7 +99,10 @@ module.exports = (function() {
* @param privatePEM {string}
*/
NodeRSA.prototype.loadFromPublicPEM = function(publicPEM, encoding) {
var pem = publicPEM.replace('-----BEGIN PUBLIC KEY-----','').replace('-----END PUBLIC KEY-----','');
var pem = publicPEM
.replace('-----BEGIN PUBLIC KEY-----','')
.replace('-----END PUBLIC KEY-----','')
.replace(/\s+|\n|\r$/gm, '');
var reader = new ber.Reader(new Buffer(pem, 'base64'));

reader.readSequence();
Expand Down

0 comments on commit fe203d6

Please sign in to comment.