rsa_digitalsignature 1.0.2 rsa_digitalsignature: ^1.0.2 copied to clipboard
A plugin for signing data with privateKey RSACNG for windows & MacOS.
RSA Digital Signature #
Library for SignData use RSACNG privateKey with support for macos, windows
Usage #
Retreive all certificate has NonRepudiation KeyUsage #
import 'package:rsa_digitalsignature/rsa_digitalsignature.dart';
import 'package:rsa_digitalsignature/certificate.dart';
final RsaDigitalsignature _rsaDigitalSignaturePlugin =RsaDigitalsignature();
final List<Certificate> _certificates = await _rsaDigitalSignaturePlugin.getCertifications();
SignData With PrivateKey #
import 'package:fast_rsa/fast_rsa.dart';
final String message = "Hello World !";
final Uint8List dataToSign = Uint8List.fromList(utf8.encode(message));
final Digest hash = sha256.convert(dataToSign);
final dynamic publickey = await _rsaDigitalSignaturePlugin.signWithprivatekey((hash.bytes as Uint8List), _selectedCertificate!.publickey);
Uint8List datasigned = Uint8List.fromList(List<int>.from(publickey as List<dynamic>));
Sign methods #
import 'package:fast_rsa/fast_rsa.dart';
var result = await RSA.signPSS(message, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, privateKey)
var result = await RSA.signPKCS1v15(message, Hash.SHA256, privateKey)
var result = await RSA.signPSSBytes(messageBytes, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, privateKey)
var result = await RSA.signPKCS1v15Bytes(messageBytes, Hash.SHA256, privateKey)
Cerificate Class #
class Certificate {
final Uint8List publickey; <-- DER Certificate
final X509Certificate x509certificate; <-- X509 Instance
final String cn; <-- Common Name
const Certificate(
{required this.publickey,
required this.x509certificate,
required this.cn});
}
Setup #
Windows #
No additional setup required.
MacOS #
No additional setup required.
Example #
Inside example folder
cd example && flutter run