本文整理汇总了C++中Crypto::getRandomValues方法的典型用法代码示例。如果您正苦于以下问题:C++ Crypto::getRandomValues方法的具体用法?C++ Crypto::getRandomValues怎么用?C++ Crypto::getRandomValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypto
的用法示例。
在下文中一共展示了Crypto::getRandomValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exceptionState
void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRandomValues", "Crypto", info.Holder(), info.GetIsolate());
if (info.Length() < 1) {
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
exceptionState.throwIfNeeded();
return;
}
v8::Handle<v8::Value> buffer = info[0];
if (!V8ArrayBufferView::hasInstance(buffer, info.GetIsolate())) {
exceptionState.throwTypeError("First argument is not an ArrayBufferView");
} else {
ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(buffer));
ASSERT(arrayBufferView);
Crypto* crypto = V8Crypto::toNative(info.Holder());
crypto->getRandomValues(arrayBufferView, exceptionState);
}
if (exceptionState.throwIfNeeded())
return;
v8SetReturnValue(info, buffer);
}
示例2: jsCryptoPrototypeFunctionGetRandomValues
EncodedJSValue JSC_HOST_CALL jsCryptoPrototypeFunctionGetRandomValues(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSCrypto::s_info))
return throwVMTypeError(exec);
JSCrypto* castedThis = static_cast<JSCrypto*>(asObject(thisValue));
Crypto* imp = static_cast<Crypto*>(castedThis->impl());
ExceptionCode ec = 0;
ArrayBufferView* array(toArrayBufferView(exec->argument(0)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
imp->getRandomValues(array, ec);
setDOMException(exec, ec);
return JSValue::encode(jsUndefined());
}