import { AES256 } from '@awesome-cordova-plugins/aes-256/ngx';
private secureKey: string;
private secureIV: string;
constructor(private aes256: AES256) {
this.generateSecureKeyAndIV();
}
...
async generateSecureKeyAndIV() {
this.secureKey = await this.aes256.generateSecureKey('random password 12345');
this.secureIV = await this.aes256.generateSecureIV('random password 12345');
}
this.aes256.encrypt(this.secureKey, this.secureIV, 'testdata')
.then(res => console.log('Encrypted Data: ',res))
.catch((error: any) => console.error(error));
this.aes256.decrypt(this.secureKey, this.secureIV, 'encryptedData')
.then(res => console.log('Decrypted Data : ',res))
.catch((error: any) => console.error(error));
* this.aes256.generateSecureKey('random password 12345')
.then(res => console.log('Secure Key : ',res))
.catch((error: any) => console.error(error));
* this.aes256.generateSecureIV('random password 12345')
.then(res => console.log('Secure IV : ',res))
.catch((error: any) => console.error(error));