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

Dependency on Node.js Buffer which crashes in Browser unless you are running from a Node Server. #1

Closed
CreepyGnome opened this issue May 1, 2019 · 2 comments

Comments

@CreepyGnome
Copy link

When you create a RijndaelBlock the constructor will convert the key to an array using its Utils.toArray function. This function if it's not already an array uses Node.js Buffer to convert it to an array. Didn't notice this as all my jasmine tests always worked because well its runs in Node. However, when I run this in a non-node environment it crashes because Buffer is undefined.

This library states it is a Pure JS library, however, having a dependency on server side Node.js kind of makes it not really pure as you compare them to two node libraries. I was depending on this not having any node.js dependencies.

I would consider this dependency a bug based on the readme.

@CreepyGnome
Copy link
Author

Okay, I was able to bypass all the uses of Buffer in encrypting except for the last one which has no if blocks around it. So the last Buffer.from used to return the encrypted data cannot be avoided and is always undefined. So I tried other crypto libs that support Rijndael and they are more complex or are not really Rijndael and are really AES. I would like to use this library, going to fork and try to find a replacement for Buffer.from but may have to use browserify which I would like to avoid.

If there are any easy ways to get Buffer to be properly defined in a browser as pure js please let me know.

@Snack-X
Copy link
Owner

Snack-X commented Oct 18, 2019

Sorry for very late response!

I've just release v2.0.0 which (hopefully) resolves this issue. New version does not use Buffer directly, and returns byte Array instead. If you are using this module in browser environment, you can convert it into Uint8Array or some other types you want.

@Snack-X Snack-X closed this as completed Oct 18, 2019
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

2 participants