| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #define _CRT_RAND_S |
| 6 #include "bin/crypto.h" |
| 7 |
| 8 |
| 9 bool Crypto::GetRandomBytes(intptr_t count, uint8_t* buffer) { |
| 10 uint32_t num; |
| 11 intptr_t read = 0; |
| 12 while (read < count) { |
| 13 if (rand_s(&num) != 0) { |
| 14 return false; |
| 15 } |
| 16 for (int i = 0; i < 4 && read < count; i++) { |
| 17 buffer[read] = num >> (i * 8); |
| 18 read++; |
| 19 } |
| 20 } |
| 21 return true; |
| 22 } |
| OLD | NEW |