Skip to content

Commit b3518ba

Browse files
Override toString for All Private Classes (#110)
* feat: override toString for _HmacSecretKey * feat: override toString in most Private Classes
1 parent 951879d commit b3518ba

22 files changed

+150
-0
lines changed

lib/src/impl_ffi/impl_ffi.aescbc.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ class _AesCbcSecretKey implements AesCbcSecretKey {
9797
final Uint8List _key;
9898
_AesCbcSecretKey(this._key);
9999

100+
@override
101+
String toString() {
102+
return 'Instance of \'AesCbcSecretKey\'';
103+
}
104+
100105
@override
101106
Future<Uint8List> decryptBytes(List<int> data, List<int> iv) async =>
102107
await _bufferStream(decryptStream(Stream.value(data), iv));

lib/src/impl_ffi/impl_ffi.aesctr.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ class _AesCtrSecretKey implements AesCtrSecretKey {
204204
final Uint8List _key;
205205
_AesCtrSecretKey(this._key);
206206

207+
@override
208+
String toString() {
209+
return 'Instance of \'AesCtrSecretKey\'';
210+
}
211+
207212
void _checkArguments(
208213
List<int> counter,
209214
int length,

lib/src/impl_ffi/impl_ffi.aesgcm.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ class _AesGcmSecretKey implements AesGcmSecretKey {
115115
final Uint8List _key;
116116
_AesGcmSecretKey(this._key);
117117

118+
@override
119+
String toString() {
120+
return 'Instance of \'AesGcmSecretKey\'';
121+
}
122+
118123
@override
119124
Future<Uint8List> decryptBytes(
120125
List<int> data,

lib/src/impl_ffi/impl_ffi.ecdh.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ class _EcdhPrivateKey implements EcdhPrivateKey {
7373

7474
_EcdhPrivateKey(this._key);
7575

76+
@override
77+
String toString() {
78+
return 'Instance of \'EcdhPrivateKey\'';
79+
}
80+
7681
@override
7782
Future<Uint8List> deriveBits(int length, EcdhPublicKey publicKey) async {
7883
if (publicKey is! _EcdhPublicKey) {
@@ -167,6 +172,11 @@ class _EcdhPublicKey implements EcdhPublicKey {
167172

168173
_EcdhPublicKey(this._key);
169174

175+
@override
176+
String toString() {
177+
return 'Instance of \'EcdhPublicKey\'';
178+
}
179+
170180
@override
171181
Future<Map<String, dynamic>> exportJsonWebKey() async =>
172182
// Neither Chrome or Firefox produces 'use': 'enc' for ECDH, we choose to

lib/src/impl_ffi/impl_ffi.ecdsa.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ class _EcdsaPrivateKey implements EcdsaPrivateKey {
185185

186186
_EcdsaPrivateKey(this._key);
187187

188+
@override
189+
String toString() {
190+
return 'Instance of \'EcdsaPrivateKey\'';
191+
}
192+
188193
@override
189194
Future<Uint8List> signBytes(List<int> data, Hash hash) =>
190195
signStream(Stream.value(data), hash);
@@ -209,6 +214,11 @@ class _EcdsaPublicKey implements EcdsaPublicKey {
209214

210215
_EcdsaPublicKey(this._key);
211216

217+
@override
218+
String toString() {
219+
return 'Instance of \'EcdsaPublicKey\'';
220+
}
221+
212222
@override
213223
Future<bool> verifyBytes(List<int> signature, List<int> data, Hash hash) =>
214224
verifyStream(signature, Stream.value(data), hash);

lib/src/impl_ffi/impl_ffi.hkdf.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class _HkdfSecretKey implements HkdfSecretKey {
2424

2525
_HkdfSecretKey(this._key);
2626

27+
@override
28+
String toString() {
29+
return 'Instance of \'HkdfSecretKey\'';
30+
}
31+
2732
@override
2833
Future<Uint8List> deriveBits(
2934
int length,

lib/src/impl_ffi/impl_ffi.hmac.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ class _HmacSecretKey implements HmacSecretKey {
107107

108108
_HmacSecretKey(this._keyData, this._hash);
109109

110+
@override
111+
String toString() {
112+
return 'Instance of \'HmacSecretKey\'';
113+
}
114+
110115
@override
111116
Future<Uint8List> signBytes(List<int> data) => signStream(Stream.value(data));
112117

lib/src/impl_ffi/impl_ffi.pbkdf2.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class _Pbkdf2SecretKey implements Pbkdf2SecretKey {
2525

2626
_Pbkdf2SecretKey(this._key);
2727

28+
@override
29+
String toString() {
30+
return 'Instance of \'Pbkdf2SecretKey\'';
31+
}
32+
2833
@override
2934
Future<Uint8List> deriveBits(
3035
int length,

lib/src/impl_ffi/impl_ffi.rsaoaep.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ class _RsaOaepPrivateKey implements RsaOaepPrivateKey {
173173

174174
_RsaOaepPrivateKey(this._key, this._hash);
175175

176+
@override
177+
String toString() {
178+
return 'Instance of \'RsaOaepPrivateKey\'';
179+
}
180+
176181
@override
177182
Future<Uint8List> decryptBytes(List<int> data, {List<int>? label}) async {
178183
return _rsaOaepeEncryptOrDecryptBytes(
@@ -204,6 +209,11 @@ class _RsaOaepPublicKey implements RsaOaepPublicKey {
204209

205210
_RsaOaepPublicKey(this._key, this._hash);
206211

212+
@override
213+
String toString() {
214+
return 'Instance of \'RsaOaepPublicKey\'';
215+
}
216+
207217
@override
208218
Future<Uint8List> encryptBytes(List<int> data, {List<int>? label}) async {
209219
return _rsaOaepeEncryptOrDecryptBytes(

lib/src/impl_ffi/impl_ffi.rsapss.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ class _RsaPssPrivateKey implements RsaPssPrivateKey {
105105

106106
_RsaPssPrivateKey(this._key, this._hash);
107107

108+
@override
109+
String toString() {
110+
return 'Instance of \'RsaPssPrivateKey\'';
111+
}
112+
108113
@override
109114
Future<Uint8List> signBytes(List<int> data, int saltLength) {
110115
return signStream(Stream.value(data), saltLength);
@@ -149,6 +154,11 @@ class _RsaPssPublicKey implements RsaPssPublicKey {
149154

150155
_RsaPssPublicKey(this._key, this._hash);
151156

157+
@override
158+
String toString() {
159+
return 'Instance of \'RsaPssPublicKey\'';
160+
}
161+
152162
@override
153163
Future<bool> verifyBytes(
154164
List<int> signature,

0 commit comments

Comments
 (0)