Rename Paddin to PlainTextPadding
This commit is contained in:
parent
06bb6e1595
commit
acc9261a66
@ -6,13 +6,13 @@ import 'dart:typed_data';
|
|||||||
import 'key.dart';
|
import 'key.dart';
|
||||||
|
|
||||||
/// Represents different cipher algorithms
|
/// Represents different cipher algorithms
|
||||||
enum CipherAlgorithm { AES, BlowFish }
|
enum CipherAlgorithm { AES, BlowFish, None }
|
||||||
|
|
||||||
/// Represents different block cipher modes
|
/// Represents different block cipher modes
|
||||||
enum BlockCipherMode { ECB, CBC, CFB, GCM, CGM }
|
enum BlockCipherMode { ECB, CBC, CFB, GCM, CGM }
|
||||||
|
|
||||||
/// Represents different padding
|
/// Represents different padding
|
||||||
enum Padding { ANSI_X923, PKCS5, PKCS7, None }
|
enum PlainTextPadding { PKCS5, None }
|
||||||
|
|
||||||
/// Represents a cipher.
|
/// Represents a cipher.
|
||||||
///
|
///
|
||||||
@ -32,6 +32,9 @@ abstract class Cipher {
|
|||||||
/// Returns true if cipher is initialized
|
/// Returns true if cipher is initialized
|
||||||
bool get isInitialized;
|
bool get isInitialized;
|
||||||
|
|
||||||
|
/// Returnes list of supported [CipherParameters] for this cipher
|
||||||
|
List<CipherParameters> get supportedParameters;
|
||||||
|
|
||||||
/// Encrypts data.
|
/// Encrypts data.
|
||||||
///
|
///
|
||||||
/// Takes [Uint8List] data as parameter.
|
/// Takes [Uint8List] data as parameter.
|
||||||
@ -62,15 +65,15 @@ abstract class CipherText {
|
|||||||
/// Represents a pair of [BlockCipherMode] and [Padding]
|
/// Represents a pair of [BlockCipherMode] and [Padding]
|
||||||
class CipherParameters {
|
class CipherParameters {
|
||||||
BlockCipherMode _mode;
|
BlockCipherMode _mode;
|
||||||
Padding _padding;
|
PlainTextPadding _padding;
|
||||||
|
|
||||||
/// Returns mode used in the cipher
|
/// Returns mode used in the cipher
|
||||||
BlockCipherMode get mode => _mode;
|
BlockCipherMode get mode => _mode;
|
||||||
|
|
||||||
/// Returns padding used in the cipher
|
/// Returns padding used in the cipher
|
||||||
Padding get padding => _padding;
|
PlainTextPadding get padding => _padding;
|
||||||
|
|
||||||
CipherParameters(BlockCipherMode mode, Padding padding) {
|
CipherParameters(BlockCipherMode mode, PlainTextPadding padding) {
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
_padding = padding;
|
_padding = padding;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ extension BlockCipherModeExtension on BlockCipherMode {
|
|||||||
String get name => describeEnum(this).toLowerCase();
|
String get name => describeEnum(this).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
extension PaddingExtension on Padding {
|
extension PlainTextPaddingExtension on PlainTextPadding {
|
||||||
String get name => describeEnum(this).toLowerCase();
|
String get name => describeEnum(this).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,13 +121,13 @@ class Utils {
|
|||||||
static CipherParameters getCipherParameters(String parameters) {
|
static CipherParameters getCipherParameters(String parameters) {
|
||||||
List<String> _query = parameters.toLowerCase().split("/");
|
List<String> _query = parameters.toLowerCase().split("/");
|
||||||
BlockCipherMode _mode;
|
BlockCipherMode _mode;
|
||||||
Padding _padding;
|
PlainTextPadding _padding;
|
||||||
for (BlockCipherMode b in BlockCipherMode.values) {
|
for (BlockCipherMode b in BlockCipherMode.values) {
|
||||||
if (_query[0] == b.name) {
|
if (_query[0] == b.name) {
|
||||||
_mode = b;
|
_mode = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Padding p in Padding.values) {
|
for (PlainTextPadding p in PlainTextPadding.values) {
|
||||||
if (_query[1] == p.name) {
|
if (_query[1] == p.name) {
|
||||||
_padding = p;
|
_padding = p;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user