changed everything from filcnaplo to refilc finally
This commit is contained in:
25
refilc/lib/api/nonce.dart
Normal file
25
refilc/lib/api/nonce.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'dart:convert';
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
||||
class Nonce {
|
||||
String nonce;
|
||||
List<int> key;
|
||||
String? encoded;
|
||||
|
||||
Nonce({required this.nonce, required this.key});
|
||||
|
||||
Future encode(String message) async {
|
||||
List<int> messageBytes = utf8.encode(message);
|
||||
Hmac hmac = Hmac(sha512, key);
|
||||
Digest digest = hmac.convert(messageBytes);
|
||||
encoded = base64.encode(digest.bytes);
|
||||
}
|
||||
|
||||
Map<String, String> header() {
|
||||
return {
|
||||
"X-Authorizationpolicy-Nonce": nonce,
|
||||
"X-Authorizationpolicy-Key": encoded ?? "",
|
||||
"X-Authorizationpolicy-Version": "v2",
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user