Fix/Update #1
							
								
								
									
										18
									
								
								melos.yaml
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								melos.yaml
									
									
									
									
									
								
							| @ -15,6 +15,24 @@ scripts: | |||||||
|   lint:all: |   lint:all: | ||||||
|     run: melos run analyze && melos run format |     run: melos run analyze && melos run format | ||||||
|     description: Run all static analysis checks. |     description: Run all static analysis checks. | ||||||
|  |    | ||||||
|  |   test:all: | ||||||
|  |     run: | | ||||||
|  |       melos run test --no-select | ||||||
|  |     description: | | ||||||
|  |       Run all tests available. | ||||||
|  |    | ||||||
|  |   test: | ||||||
|  |     run: | | ||||||
|  |       melos exec -c 6 --fail-fast -- \ | ||||||
|  |         "flutter test --no-pub --no-test-assets" | ||||||
|  |     description: Run `flutter test` for a specific package. | ||||||
|  |     select-package: | ||||||
|  |       dir-exists: | ||||||
|  |         - test | ||||||
|  |       ignore: | ||||||
|  |         - "*web*" | ||||||
|  |         - "*example*" | ||||||
| 
 | 
 | ||||||
|   analyze: |   analyze: | ||||||
|     run: | |     run: | | ||||||
|  | |||||||
| @ -91,8 +91,8 @@ class BenchmarkPage extends ConsumerWidget { | |||||||
|         after = DateTime.now(); |         after = DateTime.now(); | ||||||
|         benchmark = |         benchmark = | ||||||
|             after.millisecondsSinceEpoch - before.millisecondsSinceEpoch; |             after.millisecondsSinceEpoch - before.millisecondsSinceEpoch; | ||||||
|         benchmarkStatus |         benchmarkStatus.appendln( | ||||||
|             .appendln('[Benchmark] ${size}MiB => Decryption took $benchmark ms'); |             '[Benchmark] ${size}MiB => Decryption took $benchmark ms'); | ||||||
|         csvLine.write(';$benchmark'); |         csvLine.write(';$benchmark'); | ||||||
|       } |       } | ||||||
|       csv += csvLine.toString() + '\n'; |       csv += csvLine.toString() + '\n'; | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ | |||||||
| // ----- | // ----- | ||||||
| // File: cipher_page.dart | // File: cipher_page.dart | ||||||
| // Created Date: 28/12/2021 13:33:15 | // Created Date: 28/12/2021 13:33:15 | ||||||
| // Last Modified: 26/05/2022 21:07:54 | // Last Modified: 27/05/2022 16:42:10 | ||||||
| // ----- | // ----- | ||||||
| // Copyright (c) 2021 | // Copyright (c) 2021 | ||||||
| 
 | 
 | ||||||
| @ -60,8 +60,6 @@ class CipherPage extends ConsumerWidget { | |||||||
|       cipherText = CipherTextWrapper.fromBytes( |       cipherText = CipherTextWrapper.fromBytes( | ||||||
|         _altered, |         _altered, | ||||||
|         ivLength: AESMode.gcm.ivLength, |         ivLength: AESMode.gcm.ivLength, | ||||||
|         messageLength: |  | ||||||
|             _altered.length - (AESMode.gcm.ivLength + AESMode.gcm.tagLength), |  | ||||||
|         tagLength: AESMode.gcm.tagLength, |         tagLength: AESMode.gcm.tagLength, | ||||||
|       ); |       ); | ||||||
|       encryptionStatus.print('String successfully encrypted:\n'); |       encryptionStatus.print('String successfully encrypted:\n'); | ||||||
|  | |||||||
| @ -52,7 +52,7 @@ class CipherText extends ByteArray { | |||||||
|     CipherAlgorithm? cipherAlgorithm, |     CipherAlgorithm? cipherAlgorithm, | ||||||
|   }) { |   }) { | ||||||
|     messageLength ??= bytes.length - ivLength - tagLength; |     messageLength ??= bytes.length - ivLength - tagLength; | ||||||
|      | 
 | ||||||
|     if (ivLength.isNegative || |     if (ivLength.isNegative || | ||||||
|         messageLength.isNegative || |         messageLength.isNegative || | ||||||
|         tagLength.isNegative) { |         tagLength.isNegative) { | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import 'package:native_crypto/src/utils/cipher_algorithm.dart'; | |||||||
| /// In cryptography, a [Cipher] is an algorithm for performing encryption | /// In cryptography, a [Cipher] is an algorithm for performing encryption | ||||||
| /// or decryption - a series of well-defined steps that can | /// or decryption - a series of well-defined steps that can | ||||||
| /// be followed as a procedure. | /// be followed as a procedure. | ||||||
| ///  | /// | ||||||
| /// This interface is implemented by all the ciphers in NativeCrypto. | /// This interface is implemented by all the ciphers in NativeCrypto. | ||||||
| abstract class Cipher { | abstract class Cipher { | ||||||
|   static const int _bytesCountPerChunkDefault = 33554432; |   static const int _bytesCountPerChunkDefault = 33554432; | ||||||
| @ -26,7 +26,7 @@ abstract class Cipher { | |||||||
|   /// Returns the default number of bytes per chunk. |   /// Returns the default number of bytes per chunk. | ||||||
|   static int get defaultBytesCountPerChunk => _bytesCountPerChunkDefault; |   static int get defaultBytesCountPerChunk => _bytesCountPerChunkDefault; | ||||||
| 
 | 
 | ||||||
|   /// Returns the size of a chunk of data  |   /// Returns the size of a chunk of data | ||||||
|   /// that can be processed by the [Cipher]. |   /// that can be processed by the [Cipher]. | ||||||
|   static int get bytesCountPerChunk => Cipher._bytesCountPerChunk; |   static int get bytesCountPerChunk => Cipher._bytesCountPerChunk; | ||||||
| 
 | 
 | ||||||
| @ -35,11 +35,10 @@ abstract class Cipher { | |||||||
|   static set bytesCountPerChunk(int bytesCount) { |   static set bytesCountPerChunk(int bytesCount) { | ||||||
|     _bytesCountPerChunk = bytesCount; |     _bytesCountPerChunk = bytesCount; | ||||||
|   } |   } | ||||||
|    | 
 | ||||||
|   /// Returns the standard algorithm for this [Cipher]. |   /// Returns the standard algorithm for this [Cipher]. | ||||||
|   CipherAlgorithm get algorithm; |   CipherAlgorithm get algorithm; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|   /// Encrypts the [data]. |   /// Encrypts the [data]. | ||||||
|   /// |   /// | ||||||
|   /// Takes [Uint8List] data as parameter. |   /// Takes [Uint8List] data as parameter. | ||||||
|  | |||||||
| @ -11,8 +11,8 @@ import 'package:native_crypto/src/keys/secret_key.dart'; | |||||||
| import 'package:native_crypto/src/utils/kdf_algorithm.dart'; | import 'package:native_crypto/src/utils/kdf_algorithm.dart'; | ||||||
| 
 | 
 | ||||||
| /// Represents a Key Derivation Function (KDF) in NativeCrypto. | /// Represents a Key Derivation Function (KDF) in NativeCrypto. | ||||||
| ///  | /// | ||||||
| /// [KeyDerivation] function is a function that takes some  | /// [KeyDerivation] function is a function that takes some | ||||||
| /// parameters and returns a [SecretKey]. | /// parameters and returns a [SecretKey]. | ||||||
| abstract class KeyDerivation { | abstract class KeyDerivation { | ||||||
|   /// Returns the standard algorithm for this key derivation function |   /// Returns the standard algorithm for this key derivation function | ||||||
|  | |||||||
| @ -157,7 +157,7 @@ void main() { | |||||||
|       expect(cipherText.cipherAlgorithm, CipherAlgorithm.aes); |       expect(cipherText.cipherAlgorithm, CipherAlgorithm.aes); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
|    | 
 | ||||||
|   group('Lengths', () { |   group('Lengths', () { | ||||||
|     test('get.ivLength returns the expected value', () { |     test('get.ivLength returns the expected value', () { | ||||||
|       final CipherText cipherText = CipherText.fromBytes( |       final CipherText cipherText = CipherText.fromBytes( | ||||||
|  | |||||||
| @ -150,7 +150,7 @@ void main() { | |||||||
|         ], |         ], | ||||||
|       ); |       ); | ||||||
|     }); |     }); | ||||||
|      | 
 | ||||||
|     test('decrypt', () async { |     test('decrypt', () async { | ||||||
|       await nativeCrypto.decrypt( |       await nativeCrypto.decrypt( | ||||||
|         Uint8List(0), |         Uint8List(0), | ||||||
| @ -171,6 +171,5 @@ void main() { | |||||||
|         ], |         ], | ||||||
|       ); |       ); | ||||||
|     }); |     }); | ||||||
| 
 |  | ||||||
|   }); |   }); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user