Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crypto required but not loaded #696

Closed
fusiodarts opened this issue Jun 26, 2017 · 17 comments
Closed

Crypto required but not loaded #696

fusiodarts opened this issue Jun 26, 2017 · 17 comments

Comments

@fusiodarts
Copy link

  • Node.js Version: v7.10.0
  • OS: Ubuntu 16.04
  • Module (and version) (if relevant): crypto

Hi,

I require crypto as 'var crypto = require("crypto")', but it doesn't find the crypto functions.
I have installed the crypto module, version 0.0.3, the latest.

So, I don't know where is the problem.
I am using a NodeJS project to implement a payment gateway, using crypto but it doesn't work.
The test in this module (in node_modules folder) works fine, but in an external controller instantiating the library not.

Thanks.

@vsemozhetbyt
Copy link

vsemozhetbyt commented Jun 26, 2017

crypto is an internal Node.js module, you do not need to install it. You can uninstall the external one so it does not shadow the internal module and then just use var crypto = require("crypto").

@fusiodarts
Copy link
Author

Yes yes it is ok, but the problem is that in the test in the payment gateway project inside node_modules, it works fine, but when we call the library from an external controller, it doesn't find crypto.

We have tried to install the crypto module because it didn't work as internal NodeJS, but we receive the same result.
We have already uninstalled the crypto external module.

@vsemozhetbyt
Copy link

cc @nodejs/crypto

@addaleax
Copy link
Member

I require crypto as 'var crypto = require("crypto")', but it doesn't find the crypto functions.

Is there any chance that you can be more specific? “it doesn't find the crypto functions” doesn’t tell so terribly much…

@fusiodarts
Copy link
Author

I mean that this line don't require "crypto" if I call it from an external controller.
I need it because in the external controller where I am instantiating the library I need to use the createCipheriv function.

@addaleax
Copy link
Member

Can you share any code to reproduce the problem?

@gibfahn
Copy link
Member

gibfahn commented Jun 26, 2017

Originally raised as nodejs/node#13920

@fusiodarts
Copy link
Author

In the external controller I am instantiating var Sermepa = require('sermepa').
It instantiate the library, which requires "crypto"

@tniessen
Copy link
Member

"In the external controller", are you referring to client-side code within a browser or is this within your node process?

@fusiodarts
Copy link
Author

@gibfahn yes, it is mine. I have wrote in the incorrect platform, so the owner redirect me to this platform, sorry.

@fusiodarts
Copy link
Author

@tniessen yes, a controller inside the client folder

@tniessen
Copy link
Member

Well, crypto is a node-internal module... It is unrelated to all the stuff you do outside of the node process. Which dependency (injection) library do you use for clients? Something like require.js?

@fusiodarts
Copy link
Author

We are implementing it in the client-side because we need that the client buy a product, so we have to generate the key for the payment gateway in the client-side.

We have webpack dependency installed, but nothing as require.js

@fusiodarts
Copy link
Author

@tniessen sorry, the dependency (injection) library we are using babel

@tniessen
Copy link
Member

You could probably use https://github.com/crypto-browserify/crypto-browserify (or alternatives, never used anything like that). That should work with webpack. However, modern browsers provide the SubtleCrypto API, which might be a better choice.

Ref #432

@fusiodarts
Copy link
Author

It is ok @tniessen a lot of thanks. We are going to try it.
We implemented crypto-browserify, but we need 3DES encryption, and with crypto-browserify we only can use AES encryption.
We are going to check the Ref that you have sent me.

@tniessen
Copy link
Member

I am closing this as this problem is unrelated to node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants