Dart Encryption Library for Encrypting/decrypting Files, Plain Text

aes_crypt is a library for Dart and Flutter developers that uses 256-bit AES algorithm to encrypt/decrypt files, plain text and binary data. It is fully compatible with the AES Crypt file format. It can be used to integrate AES Crypt functionality into your own Dart or Flutter applications. All algorithms are implemented in pure Dart and work in all platforms.

aes_crypt writes and reads version 2 (latest) of the AES Crypt file specification. Backwards compatibility with reading the version 1 is implemented but untested. Output .aes files are fully compatible with any software using the AES Crypt standard file format. This library is accompanied by clients and libraries for different operating systems and programming languages. For more information about AES Crypt and AES Crypt compatible applications for other platforms, please visit AESCrypt's official website.

Features

  • 256-bit AES encryption format.
  • File-to-file encryption and decryption.
  • Memory-to-file encryption, file-to-memory decryption.
  • Password can be in Unicode (like "密碼 パスワード пароль كلمة السر").
  • Support for asynchronous file system reading/writing.
  • Encrypted files have .aes extension which clients on other operating systems recognize.
  • Compatible software available for Windows, Linux, Mac OS, Android and iOS (https://www.aescrypt.com/download/).

Usage

In your Dart code add the following import:

import 'dart:typed_data';
import 'package:aes_crypt/aes_crypt_null_safe.dart';

Initialization:

var crypt = AesCrypt('my cool password');

or

var crypt = AesCrypt();
crypt.setPassword('my cool password');

Optionally you can set overwrite mode for the file write operations:

// Overwrites the file if it exists.
crypt.setOverwriteMode(AesCryptOwMode.on);

// If the file exists, stops the operation and throws 'AesCryptException'
// exception with 'AesCryptExceptionType.destFileExists' type (see 
// example1.dart in 'example'  folder). This mode is set by default.
crypt.setOverwriteMode(AesCryptOwMode.warn);

// If the file exists, adds index '(1)' to its' name and tries to save. 
// If such file also exists, adds '(2)' to its name, then '(3)', etc. 
crypt.setOverwriteMode(AesCryptOwMode.rename);

Notice: All functions having 'Sync' at the end of their names are synchronous. If you need asynchronous ones, please just remove 'Sync' from the end of function name.

File encryption/decryption:

// Encrypts the file srcfile.txt and saves encrypted file under original name 
// with '.aes' extention added (srcfile.txt.aes). You can specify relative or 
// direct path to it. To save the file into current directory specify it 
// either as './srcfile.txt' or as 'srcfile.txt'.
crypt.encryptFileSync('srcfile.txt');

// Encrypts the file srcfile.txt and saves encrypted file under 
// the name enc_file.txt.aes
crypt.encryptFileSync('srcfile.txt', 'enc_file.txt.aes');

// Decrypts the file srcfile.txt.aes and saves decrypted file under 
// the name srcfile.txt
crypt.decryptFileSync('srcfile.txt.aes');

// Decrypts the file srcfile.txt.aes and saves decrypted file under 
// the name dec_file.txt
crypt.decryptFileSync('srcfile.txt.aes', 'dec_file.txt');

Text <=> file encryption/decryption:

String decryptedText;

// Plain text to be encrypted
String srcText = 'some text';

// Encrypts the text as UTF8 string and saves it into 'mytext.txt.aes' file.
crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes');
// Encrypts the text as UTF16 Big Endian string and saves it 
// into 'mytext.txt.aes' file.
crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes', utf16: true);
// Encrypts the text as UTF16 Little Endian string and saves it 
// into 'mytext.txt.aes' file.
crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes', utf16: true, endian: Endian.little);
// Add 'bom: true' as an argument if you want to add byte order mark 
// at the beginning of the text string before the encryption. For example:
// crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes', bom: true);

// Decrypts the file and interprets it based on byte order mark if it has one.
// Otherwise it will be interpreted as UTF8 text.
decryptedString = crypt.decryptTextFromFileSync('mytext.txt.aes');
// Decrypts the file and interprets it based on byte order mark if it has one.
// Otherwise it will be interpreted as UTF16 Big Endian text.
decryptedString = crypt.decryptTextFromFileSync('mytext.txt.aes', utf16: true);
// Decrypts the file and interprets it based on byte order mark if it has one.
// Otherwise it will be interpreted as UTF16 Little Endian text.
decryptedString = crypt.decryptTextFromFileSync('mytext.txt.aes', utf16: true, endian: Endian.little);

Binary data <=> file encryption/decryption:

// Binary data to be encrypted
Uint8List srcData = Uint8List.fromList([1,2,3,4,5]);

// Encrypts the data and saves it into mydata.bin.aes file.
crypt.encryptDataToFileSync(srcData, 'mydata.bin.aes');

// Decrypt the data from 'mydata.bin.aes' file
Uint8List decryptedData = crypt.decryptDataFromFileSync('mydata.bin.aes');

Binary data AES encryption/decryption:

// The encryption key. It should be 128, 192 or 256 bits long.
Uint8List key = Uint8List.fromList([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);

// The initialization vector used in advanced cipher modes. 
// It must be 128 bits long.
Uint8List iv = Uint8List.fromList([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);

// AES mode of operation. It can be one of the next values:
//    AesMode.ecb - ECB (Electronic Code Book)
//    AesMode.cbc - CBC (Cipher Block Chaining)
//    AesMode.cfb - CFB (Cipher Feedback)
//    AesMode.ofb - OFB (Output Feedback)
// By default the mode is AesMode.cbc
AesMode mode = AesMode.cbc; // Ok. I know it's meaningless here.

// Sets the encryption key and IV.
crypt.aesSetKeys(key, iv);
// Sets cipher mode
crypt.aesSetMode(mode);

// If you wish you can set the key, IV and cipher mode in one function.
//crypt.aesSetParams(key, iv, mode);

// The binary data to be encrypted
Uint8List srcData = Uint8List.fromList([1,2,3,4,5]);

// Encrypts the data. Padding scheme - null byte (0x00).
Uint8List encryptedData = crypt.aesEncrypt(srcData);
// Decrypts the data
Uint8List decryptedData = crypt.aesDecrypt(encryptedData);

SHA256 and HMAC-SHA256 computation:

// The source data
Uint8List srcData = Uint8List.fromList([1,2,3,4,5,6,7,8,9]);

// Computes SHA256 hash
Uint8List hash = crypt.sha256(srcData);

// Secret cryptographic key for HMAC
Uint8List key = Uint8List.fromList([1,2,3]);

// Computes HMAC-SHA256 code
Uint8List hmac = crypt.hmacSha256(key, srcData);

Acknowledgments

Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add aes_crypt_null_safe

With Flutter:

 $ flutter pub add aes_crypt_null_safe

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  aes_crypt_null_safe: ^2.0.1

Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:aes_crypt_null_safe/aes_crypt_null_safe.dart'; 

example/README.md

Download Details:

Author: CodingFries

Source Code: https://github.com/CodingFries/aes_crypt_null_safe

#encryption  #dart 

What is GEEK

Buddha Community

Dart Encryption Library for Encrypting/decrypting Files, Plain Text

Dart Encryption Library for Encrypting/decrypting Files, Plain Text

aes_crypt is a library for Dart and Flutter developers that uses 256-bit AES algorithm to encrypt/decrypt files, plain text and binary data. It is fully compatible with the AES Crypt file format. It can be used to integrate AES Crypt functionality into your own Dart or Flutter applications. All algorithms are implemented in pure Dart and work in all platforms.

aes_crypt writes and reads version 2 (latest) of the AES Crypt file specification. Backwards compatibility with reading the version 1 is implemented but untested. Output .aes files are fully compatible with any software using the AES Crypt standard file format. This library is accompanied by clients and libraries for different operating systems and programming languages. For more information about AES Crypt and AES Crypt compatible applications for other platforms, please visit AESCrypt's official website.

Features

  • 256-bit AES encryption format.
  • File-to-file encryption and decryption.
  • Memory-to-file encryption, file-to-memory decryption.
  • Password can be in Unicode (like "密碼 パスワード пароль كلمة السر").
  • Support for asynchronous file system reading/writing.
  • Encrypted files have .aes extension which clients on other operating systems recognize.
  • Compatible software available for Windows, Linux, Mac OS, Android and iOS (https://www.aescrypt.com/download/).

Usage

In your Dart code add the following import:

import 'dart:typed_data';
import 'package:aes_crypt/aes_crypt_null_safe.dart';

Initialization:

var crypt = AesCrypt('my cool password');

or

var crypt = AesCrypt();
crypt.setPassword('my cool password');

Optionally you can set overwrite mode for the file write operations:

// Overwrites the file if it exists.
crypt.setOverwriteMode(AesCryptOwMode.on);

// If the file exists, stops the operation and throws 'AesCryptException'
// exception with 'AesCryptExceptionType.destFileExists' type (see 
// example1.dart in 'example'  folder). This mode is set by default.
crypt.setOverwriteMode(AesCryptOwMode.warn);

// If the file exists, adds index '(1)' to its' name and tries to save. 
// If such file also exists, adds '(2)' to its name, then '(3)', etc. 
crypt.setOverwriteMode(AesCryptOwMode.rename);

Notice: All functions having 'Sync' at the end of their names are synchronous. If you need asynchronous ones, please just remove 'Sync' from the end of function name.

File encryption/decryption:

// Encrypts the file srcfile.txt and saves encrypted file under original name 
// with '.aes' extention added (srcfile.txt.aes). You can specify relative or 
// direct path to it. To save the file into current directory specify it 
// either as './srcfile.txt' or as 'srcfile.txt'.
crypt.encryptFileSync('srcfile.txt');

// Encrypts the file srcfile.txt and saves encrypted file under 
// the name enc_file.txt.aes
crypt.encryptFileSync('srcfile.txt', 'enc_file.txt.aes');

// Decrypts the file srcfile.txt.aes and saves decrypted file under 
// the name srcfile.txt
crypt.decryptFileSync('srcfile.txt.aes');

// Decrypts the file srcfile.txt.aes and saves decrypted file under 
// the name dec_file.txt
crypt.decryptFileSync('srcfile.txt.aes', 'dec_file.txt');

Text <=> file encryption/decryption:

String decryptedText;

// Plain text to be encrypted
String srcText = 'some text';

// Encrypts the text as UTF8 string and saves it into 'mytext.txt.aes' file.
crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes');
// Encrypts the text as UTF16 Big Endian string and saves it 
// into 'mytext.txt.aes' file.
crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes', utf16: true);
// Encrypts the text as UTF16 Little Endian string and saves it 
// into 'mytext.txt.aes' file.
crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes', utf16: true, endian: Endian.little);
// Add 'bom: true' as an argument if you want to add byte order mark 
// at the beginning of the text string before the encryption. For example:
// crypt.encryptTextToFileSync(srcText, 'mytext.txt.aes', bom: true);

// Decrypts the file and interprets it based on byte order mark if it has one.
// Otherwise it will be interpreted as UTF8 text.
decryptedString = crypt.decryptTextFromFileSync('mytext.txt.aes');
// Decrypts the file and interprets it based on byte order mark if it has one.
// Otherwise it will be interpreted as UTF16 Big Endian text.
decryptedString = crypt.decryptTextFromFileSync('mytext.txt.aes', utf16: true);
// Decrypts the file and interprets it based on byte order mark if it has one.
// Otherwise it will be interpreted as UTF16 Little Endian text.
decryptedString = crypt.decryptTextFromFileSync('mytext.txt.aes', utf16: true, endian: Endian.little);

Binary data <=> file encryption/decryption:

// Binary data to be encrypted
Uint8List srcData = Uint8List.fromList([1,2,3,4,5]);

// Encrypts the data and saves it into mydata.bin.aes file.
crypt.encryptDataToFileSync(srcData, 'mydata.bin.aes');

// Decrypt the data from 'mydata.bin.aes' file
Uint8List decryptedData = crypt.decryptDataFromFileSync('mydata.bin.aes');

Binary data AES encryption/decryption:

// The encryption key. It should be 128, 192 or 256 bits long.
Uint8List key = Uint8List.fromList([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);

// The initialization vector used in advanced cipher modes. 
// It must be 128 bits long.
Uint8List iv = Uint8List.fromList([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);

// AES mode of operation. It can be one of the next values:
//    AesMode.ecb - ECB (Electronic Code Book)
//    AesMode.cbc - CBC (Cipher Block Chaining)
//    AesMode.cfb - CFB (Cipher Feedback)
//    AesMode.ofb - OFB (Output Feedback)
// By default the mode is AesMode.cbc
AesMode mode = AesMode.cbc; // Ok. I know it's meaningless here.

// Sets the encryption key and IV.
crypt.aesSetKeys(key, iv);
// Sets cipher mode
crypt.aesSetMode(mode);

// If you wish you can set the key, IV and cipher mode in one function.
//crypt.aesSetParams(key, iv, mode);

// The binary data to be encrypted
Uint8List srcData = Uint8List.fromList([1,2,3,4,5]);

// Encrypts the data. Padding scheme - null byte (0x00).
Uint8List encryptedData = crypt.aesEncrypt(srcData);
// Decrypts the data
Uint8List decryptedData = crypt.aesDecrypt(encryptedData);

SHA256 and HMAC-SHA256 computation:

// The source data
Uint8List srcData = Uint8List.fromList([1,2,3,4,5,6,7,8,9]);

// Computes SHA256 hash
Uint8List hash = crypt.sha256(srcData);

// Secret cryptographic key for HMAC
Uint8List key = Uint8List.fromList([1,2,3]);

// Computes HMAC-SHA256 code
Uint8List hmac = crypt.hmacSha256(key, srcData);

Acknowledgments

Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add aes_crypt_null_safe

With Flutter:

 $ flutter pub add aes_crypt_null_safe

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  aes_crypt_null_safe: ^2.0.1

Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:aes_crypt_null_safe/aes_crypt_null_safe.dart'; 

example/README.md

Download Details:

Author: CodingFries

Source Code: https://github.com/CodingFries/aes_crypt_null_safe

#encryption  #dart 

Daron  Moore

Daron Moore

1598404620

Hands-on Guide to Pattern - A Python Tool for Effective Text Processing and Data Mining

Text Processing mainly requires Natural Language Processing( NLP), which is processing the data in a useful way so that the machine can understand the Human Language with the help of an application or product. Using NLP we can derive some information from the textual data such as sentiment, polarity, etc. which are useful in creating text processing based applications.

Python provides different open-source libraries or modules which are built on top of NLTK and helps in text processing using NLP functions. Different libraries have different functionalities that are used on data to gain meaningful results. One such Library is Pattern.

Pattern is an open-source python library and performs different NLP tasks. It is mostly used for text processing due to various functionalities it provides. Other than text processing Pattern is used for Data Mining i.e we can extract data from various sources such as Twitter, Google, etc. using the data mining functions provided by Pattern.

In this article, we will try and cover the following points:

  • NLP Functionalities of Pattern
  • Data Mining Using Pattern

#developers corner #data mining #text analysis #text analytics #text classification #text dataset #text-based algorithm

I am Developer

1597475640

Laravel 7 Full Text Search MySQL

Here, I will show you how to create full text search in laravel app. You just follow the below easy steps and create full text search with mysql db in laravel.

Laravel 7 Full Text Search Mysql

Let’s start laravel full-text search implementation in laravel 7, 6 versions:

  1. Step 1: Install Laravel New App
  2. Step 2: Configuration DB .evn file
  3. Step 3: Run Migration
  4. Step 4: Install Full Text Search Package
  5. Step 5: Add Fake Records in DB
  6. Step 6: Add Routes,
  7. Step 7: Create Controller
  8. Step 8: Create Blade View
  9. Step 9: Start Development Server

https://www.tutsmake.com/laravel-full-text-search-tutorial/

#laravel full text search mysql #laravel full text search query #mysql full text search in laravel #full text search in laravel 6 #full text search in laravel 7 #using full text search in laravel

I am Developer

1597559012

Multiple File Upload in Laravel 7, 6

in this post, i will show you easy steps for multiple file upload in laravel 7, 6.

As well as how to validate file type, size before uploading to database in laravel.

Laravel 7/6 Multiple File Upload

You can easily upload multiple file with validation in laravel application using the following steps:

  1. Download Laravel Fresh New Setup
  2. Setup Database Credentials
  3. Generate Migration & Model For File
  4. Make Route For File uploading
  5. Create File Controller & Methods
  6. Create Multiple File Blade View
  7. Run Development Server

https://www.tutsmake.com/laravel-6-multiple-file-upload-with-validation-example/

#laravel multiple file upload validation #multiple file upload in laravel 7 #multiple file upload in laravel 6 #upload multiple files laravel 7 #upload multiple files in laravel 6 #upload multiple files php laravel

Hollie  Ratke

Hollie Ratke

1597989600

Text Analysis Within a Full-Text Search Engine

Full-Text Search refers to techniques for searching text content within a document or a collection of documents that hold textual content. A Full-Text search engine examines all the textual content within documents as it tries to match a single search term or several terms, text analysis being a pivotal component.

You’ve probably heard of the most well-known Full-Text Search engine: Lucene with Elasticsearch built on top of it. Couchbase’s Full-Text Search (FTS) Engine is powered by Bleve, and this article will showcase the various ways to analyze text within this engine.

Bleve is an open-sourced text indexing and search library implemented in Go, developed in-house at Couchbase.

Couchbase’s FTS engine supports indexes that subscribe to data residing within a Couchbase Server and indexes data that it ingests from the server. It’s a distributed system – meaning it can partition data across multiple nodes in a cluster and searches involve scattering the request and gathering responses from across all nodes within the cluster before responding to the application.

The FTS engine distributes documents ingested for an index across a configurable number of partitions and these partitions could reside across multiple nodes within a cluster. Each partition follows the same set of rules that the FTS index is configured with – to analyze and index text into the full-text search database.

The text analysis component of a Full-Text search engine is responsible for breaking down the raw text into a list of words – which we’ll refer to as tokens. These tokens are more suitable for indexing in the database and searching.

Couchbase’s FTS Engine handles text indexing for JSON documents. It builds an index for the content that is analyzed and stores into the database – the index along with all the relevant metadata needed to link the tokens generated to the original documents within which they reside.

An Inverted index is the data structure chosen to index the tokens generated from text, to make search queries faster. This index links every token generated to documents that contain the token.

For example, take the following documents …

The inverted index for the tokens generated from the 2 documents above would resemble this…

Here’s a diagram highlighting the components of the full-text search engine …

A Text Analyzer

The components of a text analyzer can broadly be classified into 2 categories:

  • Tokenizer
  • Filters

Couchbase’s engine further categorizes filters into:

  • Character filters
  • Token filters

Before we dive into the function of each of these components, here’s an overview of a text analyzer …

Tokenizer

A tokenizer is the first component to which the documents are subjected to. As the name suggests, it breaks the raw text into a list of tokens. This conversion will depend on a rule-set defined for the tokenizer.

Stock tokenizers…

Take this sample text for an example: “_this is my email ID: _abhi123@cb.com

A couple of configurable tokenizers…

  • Exception … This tokenizer allows the user to enter exception patterns (regular expressions) over the stock tokenizers.
  • Regexp … This tokenizer extracts text that matches the pattern (a regular expression) as tokens.

For example:

#json #couchbase #search #go #text analysis #full-text search #bleve #full-text #full-text-indexing