In angular, I want to generate a MD5 hash, so I tried installing npm
modules. I tried 'crypto-js', 'angular-md5', but a lot of them with no results.
Finally, I tried with 'ts-md5' and is throwing me an error, as all the others.
First npm install --save ts-md5
and then:
import {Md5} from 'ts-md5/dist/md5';
@Injectable()
export class HeroService {
constructor(
private MD5: Md5
) { }
}
But I get the error:
[Error] ERROR – Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[HeroService -> Md5]:
StaticInjectorError(Platform: core)[HeroService -> Md5]:
NullInjectorError: No provider for Md5!
get
resolveToken
tryResolveToken
[...]
Is there a better module to encrypt in md5? How can I solve this error?
Md5
to the providers array in your app.module.ts? It would seem that is all you are missing.