2021-02-03 20:26:38 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
|
|
|
|
part 'backblaze_credential.g.dart';
|
|
|
|
|
|
|
|
@HiveType(typeId: 4)
|
|
|
|
class BackblazeCredential {
|
|
|
|
BackblazeCredential({this.keyId, this.applicationKey});
|
|
|
|
|
|
|
|
@HiveField(0)
|
2021-03-15 15:39:44 +00:00
|
|
|
final String? keyId;
|
2021-02-03 20:26:38 +00:00
|
|
|
|
|
|
|
@HiveField(1)
|
2021-03-15 15:39:44 +00:00
|
|
|
final String? applicationKey;
|
2021-02-03 20:26:38 +00:00
|
|
|
|
|
|
|
get encodedApiKey => encodedBackblazeKey(keyId, applicationKey);
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return '$keyId: $encodedApiKey';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-15 15:39:44 +00:00
|
|
|
String encodedBackblazeKey(String? keyId, String? applicationKey) {
|
2021-02-03 20:26:38 +00:00
|
|
|
String _apiKey = '$keyId:$applicationKey';
|
|
|
|
String encodedApiKey = base64.encode(utf8.encode(_apiKey));
|
|
|
|
return encodedApiKey;
|
|
|
|
}
|