Code Monkey home page Code Monkey logo

Comments (9)

zoloft avatar zoloft commented on August 27, 2024

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.

keithboesker avatar keithboesker commented on August 27, 2024

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.

zoloft avatar zoloft commented on August 27, 2024

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.

keithboesker avatar keithboesker commented on August 27, 2024

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 Wl66sRkr5vOLX3x7R9ZkOK4fB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N23btN25iipjz4TI3Mzjr8RM156QgDvB uSvYDkw0F62ZMv0fhnw0ZTYmwuoikQs5YluGv6Wt8jz0vmxKU5m56tPsn7ln0Y7LePciPAWL91ZbzYvqyoMS779NdwCww5BVqi N3rJH5JyPDWJ4wK/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.

zoloft avatar zoloft commented on August 27, 2024

Sorry @keithboesker could you please post the public key you are using to encrypt?

from jsencrypt.

keithboesker avatar keithboesker commented on August 27, 2024

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.

zoloft avatar zoloft commented on August 27, 2024

@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.

keithboesker avatar keithboesker commented on August 27, 2024

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.

zoloft avatar zoloft commented on August 27, 2024

Yes, I got the same results when tried, closing.

from jsencrypt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.