Is there any package or utilities related to crypto.subtle
present in Dart?
I found this but I believe that's read-only, not accessible and for browsers only.
I am looking for something similar for this piece of code in dart
static async CbcEncrypt(data: Uint8Array, iv: Uint8Array, key: Uint8Array): Promise<Uint8Array> {
const importedKey = await crypto.subtle.importKey(
'raw',
key,
{
//this is the algorithm options
name: 'AES-CBC',
},
false, //whether the key is extractable (i.e. can be used in exportKey)
['encrypt', 'decrypt'] //can be "encrypt", "decrypt", "wrapKey", or "unwrapKey"
);
const cipher = await crypto.subtle.encrypt(
{
name: 'AES-CBC',
iv: iv,
},
importedKey, //from generateKey or importKey above
data //ArrayBuffer of data you want to encrypt
);
return new Uint8Array(cipher);
}
I looked at various packages crypto, webcrypto, cryptography but I couldn't relate anything to the code above.
I did find a package pointycastle that looked promising. Is this thing could be a similar to crypto.subtle
??
Or Is it possible to get access to the brower's crypto.subtle object / API from Dart?