All Projects → leocavalcante → Encrypt

leocavalcante / Encrypt

Licence: bsd-3-clause
🔒 A set of high-level APIs over PointyCastle for two-way cryptography.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Encrypt

Forge
A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
Stars: ✭ 4,204 (+2012.56%)
Mutual labels:  cryptography, aes, cipher
Sboot stm32
Secure USB DFU1.1 bootloader for STM32
Stars: ✭ 181 (-9.05%)
Mutual labels:  cryptography, encryption, cipher
Swifty
🔑 Free Offline Password Manager
Stars: ✭ 496 (+149.25%)
Mutual labels:  cryptography, encryption, cipher
Oscrypto
Compiler-free Python crypto library backed by the OS, supporting CPython and PyPy
Stars: ✭ 257 (+29.15%)
Mutual labels:  cryptography, aes, rsa
Hybrid Crypto Js
RSA+AES hybrid encryption implementation for JavaScript. Works with Node.js, React Native and modern browsers.
Stars: ✭ 87 (-56.28%)
Mutual labels:  encryption, aes, rsa
Aes Rsa Java
AES+RSA结合应用java示例
Stars: ✭ 295 (+48.24%)
Mutual labels:  encryption, aes, rsa
Enigma
Enigma cipher tool
Stars: ✭ 13 (-93.47%)
Mutual labels:  cryptography, encryption, cipher
Siv Mode
RFC 5297 SIV mode of operation in Java
Stars: ✭ 22 (-88.94%)
Mutual labels:  cryptography, aes, cipher
Cryptoswift
CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift
Stars: ✭ 8,846 (+4345.23%)
Mutual labels:  cryptography, aes, cipher
Low Latency Android Ios Linux Windows Tvos Macos Interactive Audio Platform
🇸Superpowered Audio, Networking and Cryptographics SDKs. High performance and cross platform on Android, iOS, macOS, tvOS, Linux, Windows and modern web browsers.
Stars: ✭ 1,121 (+463.32%)
Mutual labels:  cryptography, aes, rsa
AES
AES for microcontrollers (Arduino & Raspberry pi)
Stars: ✭ 116 (-41.71%)
Mutual labels:  encryption, aes, cipher
Open Crypto
🔑 Hashing (BCrypt, SHA2, HMAC), encryption (AES), public-key (RSA), and random data generation.
Stars: ✭ 115 (-42.21%)
Mutual labels:  cryptography, encryption, rsa
Jsrsasign
The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES JSON Web Signature/Token in pure JavaScript.
Stars: ✭ 2,760 (+1286.93%)
Mutual labels:  encryption, aes, rsa
Gonnacry
A Linux Ransomware
Stars: ✭ 341 (+71.36%)
Mutual labels:  cryptography, encryption, aes
Mirage Crypto
Cryptographic primitives for MirageOS
Stars: ✭ 39 (-80.4%)
Mutual labels:  cryptography, aes, rsa
Encryptor4j
Strong encryption for Java simplified
Stars: ✭ 92 (-53.77%)
Mutual labels:  encryption, aes, rsa
Padding Oracle Attacker
🔓 CLI tool and library to execute padding oracle attacks easily, with support for concurrent network requests and an elegant UI.
Stars: ✭ 136 (-31.66%)
Mutual labels:  cryptography, encryption, aes
Phoenix Ecto Encryption Example
🔐 A detailed example for how to encrypt data in a Phoenix (Elixir) App before inserting into a database using Ecto Types
Stars: ✭ 166 (-16.58%)
Mutual labels:  encryption, aes
Crypto Notepad
🔑 Simple notepad for Windows with encryption features
Stars: ✭ 160 (-19.6%)
Mutual labels:  encryption, aes
Kes
KES is a simple, stateless and distributed key-management system
Stars: ✭ 168 (-15.58%)
Mutual labels:  cryptography, encryption

encrypt

Pub Package Build Status Donate

A set of high-level APIs over PointyCastle for two-way cryptography.

Looking for password hashing? Please, visit password.

Secure random

You can generate cryptographically secure random keys and IVs for you project.

Activate the encrypt package:

pub global activate encrypt

Then use the secure-random command-line tool:

$ secure-random
CBoaDQIQAgceGg8dFAkMDBEOECEZCxgMBiAUFQwKFhg=

You can set the length and the base output.

$ secure-random --help
-l, --length       The length of the bytes
                   (defaults to "32")

-b, --base         Bytes represented as base 64 or base 16 (Hexdecimal)
                   (defaults to "64")

-h, --[no-]help    Show this help message

Algorithms

Current status is:

  • AES with PKCS7 padding
  • RSA with PKCS1 and OAEP encoding
  • Salsa20

Signing

  • SHA256 with RSA

Usage

Symmetric

AES

import 'package:encrypt/encrypt.dart';

void main() {
  final plainText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
  final key = Key.fromUtf8('my 32 length key................');
  final iv = IV.fromLength(16);

  final encrypter = Encrypter(AES(key));

  final encrypted = encrypter.encrypt(plainText, iv: iv);
  final decrypted = encrypter.decrypt(encrypted, iv: iv);

  print(decrypted); // Lorem ipsum dolor sit amet, consectetur adipiscing elit
  print(encrypted.base64); // R4PxiU3h8YoIRqVowBXm36ZcCeNeZ4s1OvVBTfFlZRdmohQqOpPQqD1YecJeZMAop/hZ4OxqgC1WtwvX/hP9mw==
}
Modes of operation

Default mode is SIC AESMode.sic, you can override it using the mode named parameter:

final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
Supported modes are:
  • CBC AESMode.cbc
  • CFB-64 AESMode.cfb64
  • CTR AESMode.ctr
  • ECB AESMode.ecb
  • OFB-64/GCTR AESMode.ofb64Gctr
  • OFB-64 AESMode.ofb64
  • SIC AESMode.sic
No/zero padding

To remove padding, pass null to the padding named parameter on the constructor:

final encrypter = Encrypter(AES(key, mode: AESMode.cbc, padding: null));

Salsa20

import 'package:encrypt/encrypt.dart';

void main() {
  final plainText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
  final key = Key.fromLength(32);
  final iv = IV.fromLength(8);
  final encrypter = Encrypter(Salsa20(key));

  final encrypted = encrypter.encrypt(plainText, iv: iv);
  final decrypted = encrypter.decrypt(encrypted, iv: iv);

  print(decrypted); // Lorem ipsum dolor sit amet, consectetur adipiscing elit
  print(encrypted.base64); // CR+IAWBEx3sA/dLkkFM/orYr9KftrGa7lIFSAAmVPbKIOLDOzGwEi9ohstDBqDLIaXMEeulwXQ==
}

Fernet

import 'package:encrypt/encrypt.dart';
import 'dart:convert';

void main() {
  final plainText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
  final key = Key.fromUtf8('my32lengthsupersecretnooneknows1');
  final iv = IV.fromLength(16);

  final b64key = Key.fromUtf8(base64Url.encode(key.bytes));
  // if you need to use the ttl feature, you'll need to use APIs in the algorithm itself
  final fernet = Fernet(b64key);
  final encrypter = Encrypter(fernet);

  final encrypted = encrypter.encrypt(plainText);
  final decrypted = encrypter.decrypt(encrypted);

  print(decrypted); // Lorem ipsum dolor sit amet, consectetur adipiscing elit
  print(encrypted.base64); // random cipher text
  print(fernet.extractTimestamp(encrypted.bytes)); // unix timestamp
}

Asymmetric

RSA

import 'dart:io';
import 'package:encrypt/encrypt.dart';
import 'package:pointycastle/asymmetric/api.dart';

void main() {
  final publicKey = await parseKeyFromFile<RSAPublicKey>('test/public.pem');
  final privKey = await parseKeyFromFile<RSAPrivateKey>('test/private.pem');

  final plainText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
  final encrypter = Encrypter(RSA(publicKey: publicKey, privateKey: privKey));

  final encrypted = encrypter.encrypt(plainText);
  final decrypted = encrypter.decrypt(encrypted);

  print(decrypted); // Lorem ipsum dolor sit amet, consectetur adipiscing elit
  print(encrypted.base64); // kO9EbgbrSwiq0EYz0aBdljHSC/rci2854Qa+nugbhKjidlezNplsEqOxR+pr1RtICZGAtv0YGevJBaRaHS17eHuj7GXo1CM3PR6pjGxrorcwR5Q7/bVEePESsimMbhHWF+AkDIX4v0CwKx9lgaTBgC8/yJKiLmQkyDCj64J3JSE=
}

Signature and verification

RSA

 final publicKey = await parseKeyFromFile<RSAPublicKey>('test/public.pem');
 final privateKey = await parseKeyFromFile<RSAPrivateKey>('test/private.pem');
 final signer = Signer(RSASigner(RSASignDigest.SHA256, publicKey: publicKey, privateKey: privateKey));

 print(signer.sign('hello world').base64);
 print(signer.verify64('hello world', 'jfMhNM2v6hauQr6w3ji0xNOxGInHbeIH3DHlpf2W3vmSMyAuwGHG0KLcunggG4XtZrZPAib7oHaKEAdkHaSIGXAtEqaAvocq138oJ7BEznA4KVYuMcW9c8bRy5E4tUpikTpoO+okHdHr5YLc9y908CAQBVsfhbt0W9NClvDWegs='));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].