PointyCastle / pointycastle

Moved into the Bouncy Castle project: https://github.com/bcgit/pc-dart
MIT License
271 stars 74 forks source link

Can i use this library on browser based apps? #106

Open sureshg opened 8 years ago

sureshg commented 8 years ago

Tried using pointy castle in an Angular Dart2 app, but it failed to load the component . Is this something recommended to use in client-side apps?

Configuration used,


transformers:
  - reflectable:
     entry_points:
      - web/main.dart

import 'package:bignum/bignum.dart';
import 'package:pointycastle/api.dart';

var k = new KeyGenerator("rsa");
k.init(params);

var generateKeyPair = k.generateKeyPair();
print( generateKeyPair.publicKey);
print( generateKeyPair.privateKey);
EXCEPTION: Failed to load /packages/angular2app/app_component.html

dart:async/future.dart 197                                     Future.Future.error
package:angular2/src/platform/browser/xhr_impl.dart 11:29      XHRImpl.get.<fn>
package:stack_trace/src/stack_zone_specification.dart 135:26   StackZoneSpecification.registerUnaryCallback.<fn>.<fn>
package:stack_trace/src/stack_zone_specification.dart 206:15   StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 135:14   StackZoneSpecification.registerUnaryCallback.<fn>
package:angular2/src/core/zone/ng_zone_impl.dart 153:40        NgZoneImpl._runUnary.<fn>
dart:async/zone.dart 1146                                      _rootRun
dart:async/zone.dart 693                                       _ZoneDelegate.run
package:angular2/src/core/zone/ng_zone_impl.dart 146:21        NgZoneImpl._run
package:angular2/src/core/zone/ng_zone_impl.dart 153:7         NgZoneImpl._runUnary

Things are fine if i remove the pointycastle imports.

stevenroose commented 8 years ago

First of all, you should not only import api.dart, because it does not provide implementations of the algorithms. Import pointycastle.dart instead: it exports api.dart and impl.dart.

The error seems to be related to Angular. Did you add the Angular piece to your pubspec.yaml file?

I know this sounds silly, but try changing the transformer order (reflectable first or angular first), that might make a difference.

Luckily, the next version of Dart should support conditional imports, so we can get rid of reflectable.

stevenroose commented 6 years ago

Btw, right now, you can use PC without mirrors or reflectable.