Git Product home page Git Product logo

Comments (17)

amitaymolko avatar amitaymolko commented on August 11, 2024

Hey @bestlbw
Can you please give us some more information?
What code are you running?
Android/iOS?

from react-native-rsa-native.

bestlbw avatar bestlbw commented on August 11, 2024

@amitaymolko ios ,i need to encrypt json string that greater than 117,will return ‘undefined’,so i
try to change the code realize the block cyphers ,would u give me a example ? thanks!

from react-native-rsa-native.

amitaymolko avatar amitaymolko commented on August 11, 2024

can you send the code you are running?

from react-native-rsa-native.

bestlbw avatar bestlbw commented on August 11, 2024

the json String like this :
{"systemId":"000001","reserve1":"","reserve2":"","transflag":1,"message":{"head"{"answerCode":"000000","trxnDate":1505905415917,"trxnFlag":1,"trxnSeq":0,"trxnCode":1003},"requestBody":{"securityUserId":"bjzxmr","pageStart":1,"numberOfPages":20,"custometype":"I","searchCondition":"I","searchValue":"111","searchType":"01"}}}

from react-native-rsa-native.

amitaymolko avatar amitaymolko commented on August 11, 2024

can you please send the full code that you are running so i can properly recreate the issue on my end?

from react-native-rsa-native.

bestlbw avatar bestlbw commented on August 11, 2024

oh no ,i think u don,t know my meaning , changing the code for solving ‘unknown block type’ error

from react-native-rsa-native.

amitaymolko avatar amitaymolko commented on August 11, 2024

In order for me to recreate your issue I need a copy of the code you are running to get the ‘unknown block type’ error.

I need this to understand the issue better and things like:
What functions are you calling in the library? In what order?

from react-native-rsa-native.

bestlbw avatar bestlbw commented on August 11, 2024

ok ,i know your meaning,
const params={"systemId":"000001","reserve1":"","reserve2":"","transflag":1,"requestBody":{"securityUserId":"bjzxmr","pageStart":1,"numberOfPages":20,"custometype":"I","searchCondition":"I","searchValue":"111","searchType":"01"}}} RSA.encrypt(params, pubKey)

from react-native-rsa-native.

amitaymolko avatar amitaymolko commented on August 11, 2024

RSA.encrypt takes a string param to encrypt.

try something like:
RSA.encrypt(JSON.stringify(params), pubKey)

from react-native-rsa-native.

bestlbw avatar bestlbw commented on August 11, 2024

i know , i just omitted, until return ‘undifined’

from react-native-rsa-native.

amitaymolko avatar amitaymolko commented on August 11, 2024

So please send me full code you are running, without omitting anything.
You are making it very difficult to evaluate this issue...

from react-native-rsa-native.

bestlbw avatar bestlbw commented on August 11, 2024

cry。。。
const params={"systemId":"000001","reserve1":"","reserve2":"","transflag":1,"requestBody":{"securityUserId":"bjzxmr","pageStart":1,"numberOfPages":20,"custometype":"I","searchCondition":"I","searchValue":"111","searchType":"01"}}} RSA.encrypt(JSON.stringify(params), pubKey) return ‘undifined’

from react-native-rsa-native.

amitaymolko avatar amitaymolko commented on August 11, 2024

ok I rewrote the encrypt decrypt for iOS to handle bigger blocks of data.
Please test with latest version 1.0.10

from react-native-rsa-native.

bestlbw avatar bestlbw commented on August 11, 2024

@amitaymolko thank you very much to solve my problem,i try to change the code but no effect,thanks

from react-native-rsa-native.

earonesty avatar earonesty commented on August 11, 2024

Maybe the problem is that you cannnot encrypt blocks larger then your key with RSA. I'm guessing you're using a 1024-bit RSA key and trying to encrypt data > 128 bytes. Instead, use AES to encrypt the block and use RSA to encrypt the random AES key. This is a limitation of RSA, not of this library. When I try 2048 bit RSA and a 256 byte block, it works fine on IOS.

running this on your PEM: openssl rsa -in test.pem -text -noout | grep bit

https://www.npmjs.com/package/react-native-aes

from react-native-rsa-native.

earonesty avatar earonesty commented on August 11, 2024

Worse: it looks like the code on ios is broken if the data has a null byte in it (which it can!).

from react-native-rsa-native.

earonesty avatar earonesty commented on August 11, 2024

Do this for large data:

aeskey = random(32)
iv = random(16)
encdata = encryptaescbc(data, aeskey, iv)
enckey = encryptrsa(aeskey, publickey)
result = iv+enckey+encdata

from react-native-rsa-native.

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.