-3

we are making an app to make transactions in the polygon BlockChain.

We need to encrypt a String with Kecca256 encryption, which is what Poligon receives.

Could someone help me how to encrypt a String with that Protocol

Richard Heap
  • 48,344
  • 9
  • 130
  • 112

1 Answers1

4

As you know, a hash takes in bytes and emits bytes. So, to hash a string, you need to convert it first to bytes using a character encoding - perhaps ASCII or UTF8.

To use pointycastle import the package, construct the right digest and process the bytes.

import 'dart:convert';
import 'dart:typed_data';

import 'package:pointycastle/export.dart';

void main() {
  final digest = KeccakDigest(256);
  final hash = digest.process(ascii.encode('input'));
  print(hash);
}
Richard Heap
  • 48,344
  • 9
  • 130
  • 112