Comments (9)
mmm can you show some code? What kind of data are you trying to encrypt? Are you sure that the data you're trying to encrypt fits the key size?
from jsencrypt.
This is on a register and login form for encrypting the password into the database. I believe the issue to be with the database result. If I don't save it to database it works fine. But when I save it to database it is adding + in the whitespaces. Not sure why I'm getting whitespace.
var encrypt = new JSEncrypt();
encrypt.setPublicKey(publickey);
var password = encrypt.encrypt($('input[name="password"]').val());
var username = $('input[name="username"]').val();
var formdata = "username="+username+"&password="+password;
$.ajax({
type: "POST",
url: "assets/apps/ajax_login.asp",
data: formdata,
dataType: "html",
success: function(data){
};
}
});
from jsencrypt.
can you post some example data? What you try to encrypt, what you get as a result and what is stored in the DB. Plus you should really check that the password does not overflow the maximum size of the data that can be encrypted for your key size.
from jsencrypt.
ok this is example password: Friends@11
This is returned encrypted text before ajax sends it to database: Rgh KrIgADNiMhs4jV nKAF6OGuAhNxI6prdErJbQd tmvjQ70zrdLeVka/CLgvcpjhPT6UibML9tSaFe/dS0jMKxV9YFU9gfgws2nXI8fhPAPkIAd/1UtrgrTlNbL0oWKPYTJW6Ur3Sl5Nn0LF LMyoYpT1G 8Xcs5YJ0d9lviGHHhTqCUgemID5JN23btN25iipjz4TI3Mzjr8RM156QgDvB uSvYDkw0F62ZMv0fhnw0ZTYmwuoikQs5YluGv6Wt8jz0vmxKU5m56tPsn7ln0Y7LePciPAWL91ZbzYvqyoMS779NdwCww5BVqi N3rJH5JyPDWJ4wK/ahPdjvoKB8 5uz7ZiIWY2Da4qIDWC2O3BjkiPs1pPfB5QgGwjkXPYTHEIyGOmbsU7AAVzv6aOM YHU Utr1tHfK3XRLf6ngkWpCCV8yQFiYfppEOK1IBvADJCB6jl7IxAsSd0Yi/8zSx6Xj Wl66sRkr5vOLX3x7R9ZkOK4fBCje8XGQRqzZ5Y3bYx7EjSbzMRDBwH 7XMU IWwg6o FliKO56N3FeGJJOMIpJRiAzUl XS6KQckc9mN1b7chj rrSngFwuGlW44767wh4mOAkMnccSUGK4z2FZ3EAEorFMLURdwvs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H5JyPDWJ4wK/ahPdjvoKB8 5uz7ZiIWY2Da4qIDWC2O3BjkiPs1pPfB5QgGwjkXPYTHEIyGOmbsU7AAVzv6aOM YHU Utr1tHfK3XRLf6ngkWpCCV8yQFiYfppEOK1IBvADJCB6jl7IxAsSd0Yi/8zSx6Xj Wl66sRkr5vOLX3x7R9ZkOK4fBCje8XGQRqzZ5Y3bYx7EjSbzMRDBwH 7XMU IWwg6o FliKO56N3FeGJJOMIpJRiAzUl XS6KQckc9mN1b7chj rrSngFwuGlW44767wh4mOAkMnccSUGK4z2FZ3EAEorFMLURdwvsziS v0gOWJpC1gr4G1U2ouJ6u3AvsyaJBb7FTfrUVgc
Lots of random whitespace. Then ajax is adding + for sending to database and the database removes + but still haves whitespace.
What do you mean by overflow the maximum size of the data that can be encrypted for your key size where do I find this?
from jsencrypt.
Sorry @keithboesker could you please post the public key you are using to encrypt?
from jsencrypt.
var publickey = "-----BEGIN PUBLIC KEY-----MIICITANBgkqhkiG9w0BAQEFAAOCAg4AMIICCQKCAgByjX8JIm1MZxxSfcFEw5dSOuxi/RMLyStSutocRSzSued9GK4spVT+jWwfWTArAYf3qEsLHPueSy1xtMnouRRxCB83Da3ZJVm8AYedSFdsytWoJUEL6nHbUGOj70csQ+IECs4sYZptmuqQZy2e0cP1YOglvF5s278aD+0+bI4lCa6SnRzeI3EaZn120hzuZFXrC/7SMXYhecgVvi3odyRABShDw9NqElDH6dHm0v+KqgSxiqMN1YRCCp8/LSpNgBPJ8DO8MQZUYBbHTYOdcTsOGBo9kJywBaFQKbG7Zu0PAQS7cXHbdJbncPPhmda172PeFE2vZixmE1pCr1wa2t+XqMhwDMcNVIW1ebK+BiB9F1Sgz6Xw6YieBoximsKPrU466Kydyy0X7ND9MS/BkNXrffCPZejHaVw+atpr+xiynVHUBYPdGAJ/G4UtXZOzLfQ45Z7N26UzbX0sNe8KlPH/9owKjzhd5HenWLJIc5fq0HbQ5QsBZ4Lz1yv8J62uOqpoeD3mwfsTqYQ54jAVzlYLoXUAp/F4Yw7XElvkZpIDo71sGrH0OIYy8S2mTWgvy3pMelDYJUHXXDN7S24mldK2w9zPWxlSX3pejA9mGCiIUkVufgRjxc7buVCVc1MyZKBVc2XebOc2mYJm/y/nvkDJj8+oLvl2y4AwUSiL2Ge6ywIDAQAB-----END PUBLIC KEY-----"
from jsencrypt.
@keithboesker perfect, thank you. I will get back this evening as soon as I get home from work I will try to replicate the problem and I'll let you know.
from jsencrypt.
Well now I feel like a dumbo. I believe I fixed the issue. With ajax it using json to encrypt before sending. so my data string var formdata = "username="+username+"&password="+password; is screwing up the encrypted data before sending. But when I put the data string into a json formated string var formdata = {username: username, password: password}; it works every time like it suppose to. Thanks for the help...
from jsencrypt.
Yes, I got the same results when tried, closing.
from jsencrypt.
Related Issues (20)
- Decrypted result has wrong encoding HOT 1
- window is not defined in nuxtjs v3 HOT 8
- Suggest to add judgment when string too long
- Front-end performed RSA signature on the HMAC using SHA256, but the length was incorrect, causing the server to fail to verify it. HOT 1
- CVE-2012-5883
- An error occurred when using jsencrypt in a lower version of Chrome
- encryption returning false HOT 3
- Support node.js ? ReferenceError: window is not defined HOT 6
- Problem after upgrade to latest version from 3.2.1 on verify method
- Why is the result of each encryption different from the same content?
- [REQUEST] remove browser dependency ?
- Can the ciphertext length of JSENCRYPT 3.3.2 be controlled
- nest.js jsencrypt does not work with error `window is not defined`
- Content-Security-Policy blocked jsencryt.min.js file version 3.0.0-rc.2
- Need a fix for CVE-2023-46809 HOT 3
- Problem to decrypt in NodeJs with crypto HOT 1
- How should Java verify your generated signature HOT 1
- How to decrypt Blob、ArrayBuffer ?
- yahoo.js文件中的yui代码存在安全漏洞,是否使用最新版本的代码 HOT 4
- @3.3.2 linux public Rollup failed to resolve import HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsencrypt.