Uint8List
ecEncrypt(- dynamic data,
- dynamic publicKey
)
Implementation
Uint8List ecEncrypt(data, publicKey) {
if (!(data is Uint8List) && !(data is String)) {
throw "'data' must be a string or Uint8List";
}
if (!(publicKey is Uint8List) && !(publicKey is String)) {
throw "'publicKey' must be a string or Uint8List";
}
if (data is String) {
if (isHex(data)) {
data = hexToUint8List(data);
} else {
data = Uint8List.fromList(utf8.encode(data));
}
}
if (publicKey is String) {
if (isHex(publicKey)) {
publicKey = hexToUint8List(publicKey);
} else {
throw "'publicKey' must be an hexadecimal string";
}
}
final Uint8List curveBuf = publicKey.sublist(0, 1);
final Uint8List pubBuf = publicKey.sublist(1, publicKey.length);
switch (curveBuf[0]) {
case 1:
case 2:
default:
throw 'Curve not supported';
}
}