decryption_params.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import 'dart:convert';
  2. class DecryptionParams {
  3. final String encryptedKey;
  4. final String keyDecryptionNonce;
  5. String header;
  6. String nonce;
  7. DecryptionParams({
  8. this.encryptedKey,
  9. this.keyDecryptionNonce,
  10. this.header,
  11. this.nonce,
  12. });
  13. DecryptionParams copyWith({
  14. String encryptedKey,
  15. String keyDecryptionNonce,
  16. String header,
  17. String nonce,
  18. }) {
  19. return DecryptionParams(
  20. encryptedKey: encryptedKey ?? this.encryptedKey,
  21. keyDecryptionNonce: keyDecryptionNonce ?? this.keyDecryptionNonce,
  22. header: header ?? this.header,
  23. nonce: nonce ?? this.nonce,
  24. );
  25. }
  26. Map<String, dynamic> toMap() {
  27. return {
  28. 'encryptedKey': encryptedKey,
  29. 'keyDecryptionNonce': keyDecryptionNonce,
  30. 'header': header,
  31. 'nonce': nonce,
  32. };
  33. }
  34. factory DecryptionParams.fromMap(Map<String, dynamic> map) {
  35. if (map == null) return null;
  36. return DecryptionParams(
  37. encryptedKey: map['encryptedKey'],
  38. keyDecryptionNonce: map['keyDecryptionNonce'],
  39. header: map['header'],
  40. nonce: map['nonce'],
  41. );
  42. }
  43. String toJson() => json.encode(toMap());
  44. factory DecryptionParams.fromJson(String source) {
  45. if (source == null) {
  46. return null;
  47. }
  48. return DecryptionParams.fromMap(json.decode(source));
  49. }
  50. @override
  51. String toString() {
  52. return 'DecryptionParams(encryptedKey: $encryptedKey, keyDecryptionNonce: $keyDecryptionNonce, header: $header, nonce: $nonce)';
  53. }
  54. @override
  55. bool operator ==(Object o) {
  56. if (identical(this, o)) return true;
  57. return o is DecryptionParams &&
  58. o.encryptedKey == encryptedKey &&
  59. o.keyDecryptionNonce == keyDecryptionNonce &&
  60. o.header == header &&
  61. o.nonce == nonce;
  62. }
  63. @override
  64. int get hashCode {
  65. return encryptedKey.hashCode ^
  66. keyDecryptionNonce.hashCode ^
  67. header.hashCode ^
  68. nonce.hashCode;
  69. }
  70. }