mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
feat(plugin): add File encryption plugin (#1509)
* feat(plugin): File encryption fix #618 * typo
This commit is contained in:
parent
3d747d38b2
commit
46b4e25f7b
52
src/@ionic-native/plugins/file-encryption/index.ts
Normal file
52
src/@ionic-native/plugins/file-encryption/index.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
/**
|
||||
* @name File Encryption
|
||||
* @description
|
||||
* Simple file encryption for Cordova.
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FileEncryption } from '@ionic-native/file-encryption';
|
||||
*
|
||||
*
|
||||
* constructor(private fileEncryption: FileEncryption) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.fileEncryption.decrypt('assets/json/topSecret.json', 'secretKey');
|
||||
*
|
||||
* this.fileEncryption.encrypt('assets/json/topSecret.json', 'secretKey');
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FileEncryption',
|
||||
plugin: 'cordova-safe',
|
||||
pluginRef: 'cordova.plugins.disusered',
|
||||
repo: 'https://github.com/disusered/cordova-safe',
|
||||
platforms: ['Android', 'iOS']
|
||||
})
|
||||
@Injectable()
|
||||
export class FileEncryption extends IonicNativePlugin {
|
||||
|
||||
/**
|
||||
* Enrcypt a file
|
||||
* @param file {string} A string representing a local URI
|
||||
* @param key {string} A key for the crypto operations
|
||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||
*/
|
||||
@Cordova()
|
||||
encrypt(file: string, key: string): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Decrypt a file
|
||||
* @param file {string} A string representing a local URI
|
||||
* @param key {string} A key for the crypto operations
|
||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||
*/
|
||||
@Cordova()
|
||||
decrypt(file: string, key: string): Promise<any> { return; }
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user