Coder Social home page Coder Social logo

Comments (2)

leocavalcante avatar leocavalcante commented on July 18, 2024 3

Length 64 you mean 64 bytes, I guess, right?
AES specification limits key sizes on 128, 192, or 256 bits. A 64 bytes means a 512 bits key, which isn't supported by the algorithm itself.

Any way, the output of the HMAC256() you posted resembles a Hexdecimal string, to use this output, you should create a Key using the fromBase16 constructor. This hexdec hash itself you posted (1a991c1e2984f20af91361f916a708b1fc7e247f8f4e6cc090b89fe0280d39ed) is 32 bytes (or 256 bits) which is supported by the AES algorithm, look:

import 'package:encrypt/encrypt.dart';

void main() {
  final key = Key.fromBase16('1a991c1e2984f20af91361f916a708b1fc7e247f8f4e6cc090b89fe0280d39ed');

  assert(key.bytes.length == 32);

  final iv = IV.fromLength(16);

  final encrypter = Encrypter(AES(key));
  final encrypted = encrypter.encrypt('Lorem ipsum', iv: iv);

  print(encrypted.base16); // cbd1b4ea592191d9d9b498303e29bfe0
}

from encrypt.

satheler avatar satheler commented on July 18, 2024

Sorry, I didn't know that specification. Thank you very much.

from encrypt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.