crypto_x

Creator: coderz1093

Last updated:

Add to Cart

Description:

crypto x

crypto_x #


A Dart library for encryption and decryption. Advanced RSA, AES based on pointycastle.
Features #

RSA with PKCS1 and OAEP encoding.
Generate RSA KeyPairs and import to pem format.

Getting started #
Add the package to your pubspec.yaml:
dependencies:
crypto_x: <latest_version>
copied to clipboard
Usage #
AES #
Supported modes are:

CBC AESMode.cbc
CFB-8 AESMode.cfb8
CFB-128 AESMode.cfb
CTR AESMode.ctr
ECB AESMode.ecb
OFB-128 AESMode.ofb

final key = CipherKey.fromUtf8('your key................');
final iv = CipherIV.fromLength(16);
var aes = AES(key: key, mode: AESMode.cbc);
CryptoBytes encrypted = aes.encrypt(CryptoBytes.fromUTF8('hello world.'), iv: iv);
String encryptedBase64 = decrypted.base64;
CryptoBytes decrypted = aes.decrypt(encrypted, iv: iv);
String plainText = decrypted.toString();
copied to clipboard
RSA #

encrypt and decrypt

var privateRSA = RSA(
privateKey: privateKey);
var publicRSA = RSA(
publicKey: publicKey);
CryptoBytes signature = publicRSA.encrypt(CryptoBytes.fromUTF8('hello world'));
String ciphertext = signature.base64;
CryptoBytes plainBytes = publicRSA.decrypt(signature);
String plainText = plainBytes.toString();
copied to clipboard

sign and verify

var rsaSigner = RSASigner(digestType = DigestType.sha256, privateKey: privateKey, publicKey: publicKey);
var plainBytes = CryptoBytes.fromUTF8('hello world');
CryptoBytes signature = rsaSigner.sign(plainBytes);
bool isSame = rsaSigner.verify(signature, plainBytes);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.