encryparamater method

ParameterRegisterNew encryparamater(
  1. Sodium sodium,
  2. String message,
  3. String type
)

Implementation

ParameterRegisterNew encryparamater(
    Sodium sodium, String message, String type) {
  final plainTextBytes = message.toCharArray().unsignedView();
  var aab = base64Decode(
      type == "clubWallet" ? Config().keyclubWallet :
      type == "clubkey" ? Config().keyclub :
      type == "apikey" ? Config().keyapikey :
      type == "register" ? Config().keypublicregister :
      Config.keypublicregisterSosmed);

  final nonce = sodium.randombytes.buf(sodium.crypto.box.nonceBytes);
  final securekey = sodium.crypto.box.keyPair();
  var publickey = base64Encode(securekey.publicKey);
  var secret = base64Encode(securekey.secretKey.extractBytes());

  try {
    final timer = Stopwatch()..start();
    final cipherText = sodium.crypto.box.easy(
        message: plainTextBytes,
        nonce: nonce,
        publicKey: aab,
        secretKey: securekey.secretKey);

    timer.stop();

    var aa = base64Encode(aab);
    var bb = base64Encode(nonce);
    var cc = base64Encode(cipherText);

    // print("bla1 // baby // publickey ==> $publickey");
    // print("bla2 // token // nonce ==> $bb");
    // print("bla3 // booom // data ==> $cc");
    // print("type // type // data ==> ${type}");
    ParameterRegisterNew result =
    ParameterRegisterNew(bla1: publickey, bla2: bb, postData: cc);
    return result;
  } finally {}
}