GithubHelp home page GithubHelp logo

juhoen / hybrid-crypto-js Goto Github PK

View Code? Open in Web Editor NEW
140.0 7.0 40.0 830 KB

RSA+AES hybrid encryption implementation for JavaScript. Works with Node.js, React Native and modern browsers.

Home Page: https://github.com/juhoen/hybrid-crypto-js

License: MIT License

JavaScript 100.00%
rsa-aes rsa aes-256 aes encrypt decrypt hybrid node nodejs hybrid-crypto-js

hybrid-crypto-js's People

Contributors

cintolas avatar juhoen avatar simomat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hybrid-crypto-js's Issues

Build issue for Android

I havent yet found a way to resolve this issue:
image

I've tried to follow the steps provided by android studios but they did not seem to resolve the issue

Verify not working

Hello
crypt.varify is not working, getting below error:

/home/hyper1/Sawtooth-projects/auth/node_modules/node-forge/lib/util.js:1602
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
^

TypeError: input.replace is not a function
at Object.util.decode64 (/home/hyper1/Sawtooth-projects/auth/node_modules/node-forge/lib/util.js:1602:17)
at Crypt.verify (/home/hyper1/Sawtooth-projects/auth/node_modules/hybrid-crypto-js/lib/crypt.js:48:32)
at Object. (/home/hyper1/Sawtooth-projects/auth/server.js:36:19)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:240:19)

Encrypt and decrypt an object

when I encrypt an object instead of only a string as in the example , I get no error but when tried to decrypt it , I only get the output as [object object], I can't get the real data , am I doing something wrong or hybrid-crypto-js can only encrypt and decrypt simple strings

Unable to RSA decrypt in PHP openssl

Decryption using PHP Openssl 1.1.1w fails for a Cipher encrypted using hybrid-crypto-js v4.2.0.
I have verified that the key pair matches.
Is there anything else I am missing here? Kindly help.

JavaScript:

const publicKey = "returned from php reading public_key.pem";
const plainText = "plain text here";
var crypt = new Crypt();
var encryptedText = crypt.encrypt(publicKey, plainText);
// send JSON.parse(encryptedText).cipher to php

PHP:

$privateKey = file_get_contents("./private_key.pem");
$ret = openssl_private_decrypt(base64_decode($_GET['encrypted_text']), $decryptedText, $privateKey);
if (!$ret) echo "decryption failed";
else echo "Decrypted Text: " . ($decryptedText);

Newbie Question: How to with React?

Pardon me for the newbie question, but this is the first time doing this sort of thing. I'm in the process of building a chat functionality for my web app (not native) and curious how to implement this? All my chats are one-to-one in the context of a conversation and each user is assigned a participant for the conversation.

How should I go about generating and storing the keys? I read an article somewhere of using the username to generate the key? Should it be stored in the database so the other member of the chat conversation can retrieve? I'm just confused on the overall process I guess.

crypto only works whilst remote debugging

Hi again!
I have noticed that this library only works while being connected to the remote debugging. I think it has to do with crypto having a dependency towards node which is not available outside the remote debugger.

Would be happy if someone knows a workaround
Thanks!

Linker Error when building to ios device

Hello! I'm just getting to the point where I'm needing to get this on my device for further testing and I ran into this error when building:

image

I wasn't sure if this should be something that is built into the package itself and taken care of at react-native link or if I should do what the error suggested and disable the bitcode. Is this something that can be looked into and see if it may be an easy fix for the package?

Initialization vector length for encryption not customizable

The initialization vector (IV) is a common parameter for several encryption algorythms and is chosen randomly to enhance encryption relyability. At least for AES, the length of IV is variable and thus should be customizable.

In current implementation, an IV length of 32 byte is hardcoded:

const iv = forge.random.getBytesSync(32);

This makes it incopatible with certain decryption standards which assume a different length of IV.

Possible solution: make IV length a parameter.

Allow for other Message Digests than SHA1 when signing

Hey there! I am just wondering if you have any plans to support other message digests than sha1 when signing. I am currently using SHA256 in a project and would love the possibility of freely switching between SHA1, SHA256 or w/e forge has support for!

Thanks in advance!

Unable to save decrypted image.

I think this might not be entirely an issue with this library as the same code essentially work in react native, but on the web, the file generated by the JS is constantly "corrupted".

imageData = crypt.decrypt(privateKey(), encrypted).message;

The data coming out from that doesn't seem to be the same in react native and the web for binary data.

I save it off to a file and compare the size is different, original 1.9m vs encrypted and decrypted 1.8m

[RN 0.60.4] Error on IOS release build

On IOS simulator and Android build, There has no problem at all.
But, on IOS release build, it doesn't work.

Here is my error message for it. please check below.

Versions

  • React-Native 0.60.4
  • hybrid-crypto-js 0.2.2
  • IOS 13.3

IOS
2020-03-17 17:31:27.247
[error][tid:com.facebook.react.JavaScript] 'Unhandled promise rejection', { [TypeError: null is not an object (evaluating 'y.getRandomBase64')]
line: 2856,
column: 819,
sourceURL: '/private/var/containers/Bundle/Application/549634BA-2C25-495E-B9E5-08E1FCD66F52/myApp.app/main.jsbundle' }
2020-03-17 17:32:20.098 [info][tid:com.facebook.react.JavaScript]

How to decypt data with php

Please tell me how to decrypt the data using the php.
Actually i encrypted the data using hybrid-crypto-js.
So i want to decrypt using backend php.

Error: Invalid PEM formatted message, while using "var encrypted = crypt.encrypt(publicKey, message);"

All steps done for using this library, but getting below error,
Error: Invalid PEM formatted message. at Object.pem.decode (pem.js:185) at Object.pki.publicKeyFromPem (x509.js:752) at crypt.js:69 at Array.map (<anonymous>) at Crypt.encrypt (crypt.js:67) at App.js:117 at tryCallOne (core.js:37) at core.js:123 at JSTimers.js:289 at _callTimer (JSTimers.js:146)

while using
var encrypted = crypt.encrypt(publicKey, message);
Please suggest some solution to it, as I need to encrypt plain text using public key received from an API.

How do I use this for payloads?

When I use this lib to encrypt payload, I got:

  "encryptedPayload": "{\"v\":\"hybrid-crypto-js_0.2.4\",\"iv\":\"rhYAMZoSP6fqub6r2b+XLqBUGWh6Kos86Pq6dkKF+s4=\",\"keys\":{\"a1:e5:a0:3a:d5:b4:c5:ac:af:9f:16:17:33:de:f9:8e:4a:b6:99:46\":\"Yj878Aa+rXbh9oVzWE6fdjxcQ3ZHum0LWyFYNvnt9QEi/7YZFmnHLFIJXfDq/4mJa9zxAXrJhhyXFd8P7ukoGtntlPJMc2EW7xjU3DBEzJoI4gCNdkhx+3/QDOfOA2Baop7A7QX3YKank+2uFxM9Fro44oihd2zVAm2sXBbXBejNQtor9drcKWTYYS1UGhvcqxkgEmXZ2UrL/uxTmmQrYfhe2DWREG7ryZOAPrao5ZyrtWQehctGlR+hIdqcWI6m9DwAIBCwplMpL3k8kmFD+q2kiJPeXJkuc6Z2kMlCcwt8UteY5SsEyx78l29/RZmzgwX/gwj01LjgITay9f+glW8eXmbcZ576zZjHDGkgtnZXqMdulV8C3HsKo3f8JDJBMKMTXiaX7ApX9XBNuHEJC17J6fkJGDJ40T2TDclefmCadthQnYTI3DuAoAk9oznuqkc7cfOwoXiuD/j8AbtrjxtccbinJ69MC8XOk9qEotd+XJcL+7FfklEl3YkEfnEO3HJch/ipYlE4VSxfOtQNugo5dCIMckU7I96lSSTuZPilEHvJ5jbjL+/6xtTF94wOu+Pjh1SYPgA4pN/VBB6aOix7ftHT6OkG5LrKiYmtG58c8PY2w/kjp0pu6zVta94FLAjuQamrQh+aBp6OtWCoAW3KOj/0lJAtDioOZW0Mj3P7EsaLEj1QU0ZR0EaT9yWUxUsnESCwlOJq2ngnhpr8TH87G2tw48xQy/rJCiDurvCg8HVpq4LDZZwWkFDz3qA0EqV48X4QmAVMY1PLjvxvWA/SEXkRuAS9haBeK3zgTqc22T3EnXw+bFOCwnH0xDD4X4ROoAICAcTURItK710KQ63Mn35jya8fhXJ/+No4h0kt7aqvCEAL8lKUXn0TI+iUptecyTyLm+N39zleSOKOETHXLGLtNI2Fui5V5khu0NMlwOkzzQ8g0/Be8lKdlwEgwO1tZdyusFOhRBrtF22MaahVFdMsALqMFp0jJ30SFY0ecAgkSjLca70MU/tm7apmhmh2hxtYyR5JGOS2/WTbnX6kplGbtlj2sVUfV72+N9zQ5ms6pfdPPXNJ+YLQm+Jm9l7UnOjEk1l+RzUKuju/LMtwS05R6Ja95j6I/wU7Wk/lI1cst3qZHNWJysPJ6P3NoJjZnl14+ROsu/T61bcVHOhegtDpb3+lIDGVuEgDAlm1MEKCT2uCPSvZxqT53MNiXWGnRtAzM1pCTcx19Pob+pc/fEclg8qI21Tr47qDZ80QRl5DHdXoq6ewvD7PvhxysSq43xNB5lENU7iD1H0MGvXxk07pSwewaSNvrtBuc30W91XzOyLOHWko+yFy6vltv0jnT2nBJTMxlQr+5QkOmA==\"},\"cipher\":\"7yE6SzfngU0vvY9Es8wQ/ADU8IpI6q4eE+YP4PVg81rp8/zH23R63dpx7O8VlJDDcFrVdIfLZwBpToFoC1Pkz31QbjAarBXSEVKcDnyzV3c=\"}",
}

When I decrypt this,

 "decrypted": Object {
    "message": "[object Object]",
    "signature": undefined,
  },

How can I use this lib to encryption and decryption of a payload?

Can't decrypt the AES Key

Hi, I need to do the decryption in C# code but i can't Decrypt the Key pairs. i can't get the AES key. i have used online tools to decrypt the RSA and tried to get actual AES key but it's showing undefined characters after decryption

Crypt or crypt is not defined hybrid-crypto.min.js

I use hybrid-crypto.min.js in local file,open in brower for testing.
when use new Crypt() or new crypt() ,both exception is 'Uncaught TypeError: (C)crypt is not a constructor'.
must use in webpack?
can anyone help?

"Cannot read property 'toString' of undefined" on decryption

Hi,

I was testing around with your library because I would like to use it. But I have some problems with the decryption. I tested the solution below in frontend and also backend (NodeJs v12.18.3). When I try to decrypt I just get the error Cannot read property 'toString' of undefined.

var rsa = new RSA();

var crypt = new Crypt({
    aesStandard: 'AES-CBC',
    rsaStandard: 'RSA-OAEP'
});

var encryptedH = crypt.encrypt(document.getElementById("pubkey").value, {
    title: 'some title',
    email: 'some email',
    name: 'some name,
    phone: 'some phone number,
    text: 'some text',
    checkbox: true,
});
console.log('encrypted: ', encryptedH)
/* -- OUTPUT
{"v":"hybrid-crypto-js_0.2.3","iv":"QRor2uyFnhdgqXtUxDB7o9LbSaFXK6odaSHtpDL16mI=","keys":{"08:3a:15:70:7b:f4:c1:27:57:b6:37:b9:f3:a0:dc:df:eb:22:08:1d":"Vn2faFPhh2xoaXSa3ghAyNbo11E2KbCAEqwwlD93JUAMakUpOzE3GcdiXOB55U6Agbyak5pCeEXjG9fbMw+o8xlKGRUiUUcEsiT02s9sTSQemAAVBydBwa+UXa6iu033qHJ0I++uFo8vQRObgyMKl8/n2HKD52yf6Vt19b6mMVU="},"cipher":"1zO+TYohl6CRey7BRwq5bA=="}
*/
var decryptedH = crypt.decrypt(document.getElementById("privkey"), encryptedH);
console.log('decrypted: ', decryptedH)
// OUTPUT: Cannot read property 'toString' of undefined

My private key

-----BEGIN RSA PRIVATE KEY-----
MIICWgIBAAKBgG4kvYupwwOdvEtVTur2/ECBObfgok0tUhGX1laspI4s5tMbF1y2
TtROf+S6u2qxaSfhy5bG+hT0dnaSAtLjAxqFEE68oVFV/N6wnZnTI2Ca+QptVzUZ
TIuLS1ccLy9yAKADQ3JsJ9vXJpolLbwXh9YphAuOCBELmiD0R0hFBWGxAgMBAAEC
gYBT+eEmTc1owWehjC46SQs0ZxJJlpRIAWjUDw8VUFW6LJPkmoAqaLkbd6pdCt3/
z7nb9XSSxaxAM87qQhKzFO/002fMjhj6tuMHUdQWLxXfVcM5GC3XB62JeJ8cGS/s
qeeeovObj9mKjPzdiGRBY20uATVdGf+1pi1KPp/7jl96zQJBAL0afB0sdn7SBxNB
2MrZRgcqZhhDW7X54udREB3cJm/2dJA2owCiRdgrcb5ww7Q9ikbkJYIi8D8d+DRd
2QqF3jMCQQCVG4QCnzSncHKL5VZWSuvhLsm8b90xJt5SkGtg0O18bPS74K4PMA3c
JSQpuENURUs2TDtyPZxYNc2Artuh31SLAkA+64cMdfTfcaalA63MoMqqK7NYs2Da
hdC3wsMoDE5Fxq02JtfJqDSxHpN0GDUlzawqtlK8oD9r4N7rHabP14b9AkBQjV3i
wLmEX3YyZ4Id+jm2HD22BETdwd7HgefQlO5HkuEgAoBmChLixFnmA/qzsv+v5L0U
uX4WFXLguxZCO9GDAkBh0S0hd6msX/014jEI+dcKkFdASpY7/R3d5PTOlWOrp3oN
cyPVBc1HYx949eB2BrV2AG9AgKtXiA4Jd+ox+jMY
-----END RSA PRIVATE KEY-----

My public key

-----BEGIN PUBLIC KEY-----
MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgG4kvYupwwOdvEtVTur2/ECBObfg
ok0tUhGX1laspI4s5tMbF1y2TtROf+S6u2qxaSfhy5bG+hT0dnaSAtLjAxqFEE68
oVFV/N6wnZnTI2Ca+QptVzUZTIuLS1ccLy9yAKADQ3JsJ9vXJpolLbwXh9YphAuO
CBELmiD0R0hFBWGxAgMBAAE=
-----END PUBLIC KEY-----

If anybody knows what my mistake is, thank you.

ReferenceError: Crypt is not defined

Initializing Crypt() wont work. Console gives an error Uncaught ReferenceError: Crypt is not defined. I have tried initializing it like so var crypt=new Crypt();. I am trying to encrypt data on the client's browser. I have used this hybrid-crypto.min.js
Please assist me! I'm still new to JavaScript and might be missing something very simple.
I'm stuck and want to complete the project i am working on.

bytes is not defined

Getting below error:

bytes = forge.util.encodeUtf8(String(input));
^
ReferenceError: bytes is not defined

publicKey.encrypt is not a function

I got this error
privateKey.sign is not a function
in the below code:
var signature = crypt.signature(privateKey, text);
Also
publicKey.encrypt is not a function
in here:
var encrypted = crypt.encrypt(publicKey, text);
Does anyone know about this?

How many public keys in Encryption

Hi,

var encrypted = crypt.encrypt([publicKey1, publicKey2, publicKey3], message);

Regarding encrypting with multiple public keys , is there any limit on how many public keys it can encrypt with ?
If there is a limit , can it be increased ?

Thanks,
Chitta

Typescript annotations in JS?

Hi,

I checked out your source code and found it quite odd to see typescript annotations within JS files.
So my question: what part exactly transpiles it? Babel? Is that feature documented anywhere?
And why not go with Typescript then?

Regards

Error Module not found: Error: Can't resolve 'react-native'

Hello all,

I am using hybride-crypto-js with webpack but getting below error:

ERROR in ../node_modules/hybrid-crypto-js/lib/keymanager.js
Module not found: Error: Can't resolve 'react-native' in '/home/hyper1/Sawtooth-projects/webpkdemoo/node_modules/hybrid-crypto-js/lib'
@ ../node_modules/hybrid-crypto-js/lib/keymanager.js 1:0-42 30:8-20 40:8-20
@ ../node_modules/hybrid-crypto-js/lib/index.js

Can anyone help me to solve this issue?

How can a hash be created without using a key?

I want to create an SHA-1 hash of some date, the examples show using a key when using the signature method.
I don't want to use a key (I'm communicating with a server which doesn't use one), yet there seems no way to create a signature without using one?

Web - Decryption Not Working - Invalid RSAES-OAEP padding

On the web, I am unable to get decryption working. I keep getting the error "Error: Invalid RSAES-OAEP padding." when decrypting. Here is the code sample I am trying:

var privateKey = '-----BEGIN RSA PRIVATE KEY-----\r\nMIIJKAIBAAKCAgEA1t6LreeZakBC/CdxAVKjJa0kT6E2EHGz7avKmo5P+MDqqJqH\r\nTCRgDz/Gfn2M3wBTK0JbXBKGWpOe8YEH3/CYJTLdMrPceA9AnumMvPVMOk02jlmz\r\n+eKn8zW0EUx6egF8yF1TcLVKQcxR//nbAZEY5YqRs1q6yL35s62ZY5W+ZvaaBFYM\r\nXPHMYEunrDBWwlvuyK2WRYDlKd+ELY+6OcvCJBBkT0SNwBVxz0mNXaqGrv5U9kcS\r\nES6RRJjAXd4PokDcn3kXfYps7cPDPjqLovRB46bsnDms1G4bU/mty6o2i2HJSkmj\r\nmqanSlKj2fcm3PGizML7dSTHZZSeQ2tlTmh51QiqTwOTY9cR4sDKEP/+ylEKAvqF\r\nXFwH3uIL8SUTeUqr9JlDjIA6NVIr7pRzRdqIYKP68iFWh2Han4NFvlObfKr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Yps7cPDPjqLovRB\r\n46bsnDms1G4bU/mty6o2i2HJSkmjmqanSlKj2fcm3PGizML7dSTHZZSeQ2tlTmh5\r\n1QiqTwOTY9cR4sDKEP/+ylEKAvqFXFwH3uIL8SUTeUqr9JlDjIA6NVIr7pRzRdqI\r\nYKP68iFWh2Han4NFvlObfKrxI6XtqhYabRJ5CXA2cAd4zRVCDrMacz76TjbUKVPC\r\nbUIR8d+cS91qi+0By4w12SC8+c1pt6ZHWOhLH8+Rp1JThpibJVXXqj63zmGdY9j6\r\n0envsLKy9oEfGZiB8CtEFj5kHVujcufXvslLJkHj7NlZfpoqm5d/rtxELmg3aazS\r\nEi4FdF94hHnW/DasrFP1GiOTAh+0+s9y80PDQVgikpe9k1ieICgHUpM5EmWDndAU\r\nf6wE/PR/1ERPH8/ODFr3Mo0CAwEAAQ==\r\n-----END PUBLIC KEY-----\r\n';


var crypt = new Crypt();

var message = 'Hello world!';

// Encrypt message with single public key
var encrypted = crypt.encrypt(publicKey, message);
console.log("encrypted", encrypted)

// Decrypt message with corresponding private key
var decrypted = crypt.decrypt(privateKey, encrypted).message;
console.log("decrypted", decrypted)

Uncaught SyntaxError: Unexpected token '<' (at prime.worker.js:1:1)

Built the react app which uses the hybrid-crypto-js. On built deployed there is a request to forge/prime.worker.js

var rsa = new RSA();
rsa.generateKeyPair((key) => {
    const publicKey = key.publicKey;
    const privateKey = key.privateKey;
    setPublicKey(publicKey);
    setPrivateKey(privateKey);
    setLoaded(true);
});

This is the code in that component. The same build when run on local runs fine i.e, on localhost, but with some domain it fails.

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.