Closed murali-shris closed 4 years ago
Let me take a look
The reason for your problem is, that the result of createSHA256Signature
is not a UTF-8 encoded string.
Here is your code bit working.
import 'dart:convert';
import 'package:crypton/crypton.dart';
void main() {
var rsaKeypair = RSAKeypair.fromRandom();
var message = 'test message';
var signature = rsaKeypair.privateKey.createSHA256Signature(utf8.encode(message));
var signatureStr = base64Encode(signature);
var verified = rsaKeypair.publicKey.verifySHA256Signature(utf8.encode(message), base64Decode(signatureStr));
print(verified);
}
I'll upload a fixed version of the deprecated RSA function createSignature
and verifySignature
to pub.dev
Does that resolve your issue?
The reason for your problem is, that the result of
createSHA256Signature
is not a UTF-8 encoded string.Here is your code bit working.
import 'dart:convert'; import 'package:crypton/crypton.dart'; void main() { var rsaKeypair = RSAKeypair.fromRandom(); var message = 'test message'; var signature = rsaKeypair.privateKey.createSHA256Signature(utf8.encode(message)); var signatureStr = base64Encode(signature); var verified = rsaKeypair.publicKey.verifySHA256Signature(utf8.encode(message), base64Decode(signatureStr)); print(verified); }
I'll upload a fixed version of the deprecated RSA function
createSignature
andverifySignature
to pub.devDoes that resolve your issue?
yes it does.. Thanks a lot for your quick response.
:)
Code:
Output:
I upgraded from version 1.0.6 to 1.1.0. I changed createSignature (deprecated) to createSHA256Signature.