Skip to content

Polyfill for crypto #186

Description

@tolotrasamuel

When using uuid, it fails because of:
https://github.com/uuidjs/uuid#getrandomvalues-not-supported

It would be great to have the native platform (Android, iOS or even just Dart) polyfill crypto.getRandomValues

function insecureRandomValues (array: Uint8Array): Uint8Array {
  let r = 0;

  for (let i = 0; i < array.length; i++) {
    if ((i & 0x03) === 0) {
      r = Math.random() * 0x100000000;
    }
    array[i] = (r >>> ((i & 0x03) << 3)) & 0xff;
  }

  return array;
}

works but is insecure

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions