app_security_kit 0.0.1
app_security_kit: ^0.0.1 copied to clipboard

Flutter Android iOS

Flutter Plugin for application to preform series of security related functions

app_security_kit #

app_security_kit is a plugin for application preform series of security related actions e.g. creating public/pricate key, encode/decode string.

Usage #

RSA functions #

import 'package:app_security_kit/app_security_kit.dart';
import 'package:pointycastle/export.dart';

RsaKeyHelper rsaHelper = RsaKeyHelper();

/// Generate Key pairs
AsymmetricKeyPair keyPairs = rsaHelper.generateKeyPair();

/// Convert Keys into String
String publickeyPem = rsaHelper.encodePublicKeyToPem(keyPairs.publicKey);
String privatekeyPem = rsaHelper.encodePrivateKeyToPem(keyPairs.privateKey);

/// Convert String back into Keys
RSAPublicKey pbkeyFromPem = rsaHelper.parsePublicKeyFromPem(publickeyPem);
RSAPrivateKey pvkeyFromPem = rsaHelper.parsePrivateKeyFromPem(privatekeyPem);

/// Encrypt String
String encryptedString = rsaHelper.encrypt("Testing String", keyPairs.publicKey);

/// Decrypt String
String decryptedString = rsaHelper.decrypt(encryptedString, keyPairs.privateKey);

Retrieve class #

Extends from Retrieve

import 'package:app_security_kit/retrieve.dart';
import 'package:flutter/material.dart';

class TestRetrieve extends Retrieve {
  final String retrieve;
  final DateTime dateTime;

  final String customVal1;
  final String customVal2;

  TestRetrieve({
    @required this.retrieve,
    @required this.dateTime,
    @required this.customVal1,
    this.customVal2,
  }) : super(retrieve: retrieve, dateTime: dateTime);

  @override
  String toString() {
    return "retrieve=$retrieve&seq=$seq&customVal1=$customVal1${customVal2 != null ? "&customVal2=$customVal2" : ""}";
  }

  Object toJson() {
    return {
      "retrieve": retrieve,
      "seq": seq,
      "customVal1": customVal1,
      "customVal2": customVal2 == null ? '' : customVal2,
    };
  }
}

Generate Sign for api retrieve

DateTime testDateTime = DateTime.parse("2021-01-01");
TestRetrieve testRetrieve = TestRetrieve(
    retrieve: "testing",
    dateTime: testDateTime,
    customVal1: "cusVal1",
);

/// Using the Private Key to create sign
testRetrieve.setSign(keyPairs.privateKey);

License #

MIT

0
likes
90
pub points
0%
popularity

Flutter Plugin for application to preform series of security related functions

Homepage

Documentation

API reference

Uploader

damon.leong@goldhub.hk

License

MIT (LICENSE)

Dependencies

asn1lib, flutter, pointycastle

More

Packages that depend on app_security_kit