我正在开发一项功能,该功能需要 Aes 加密(AES/CBC/PKCS5padding)密文从客户端发送到后端有 ASP.Net 的服务器。
我在服务器端有一个解密功能,如下所示:
public static string Decrypt(string inputBase64, string passphrase = null)
{
byte[] key, iv = new byte[0];
byte[] base64data = Convert.FromBase64String(inputBase64);
byte[] passphrasedata = RawBytesFromString(passphrase);
byte[] currentHash = new byte[0];
SHA256Managed hash = new SHA256Managed();
currentHash = hash.ComputeHash(passphrasedata);
return DecryptStringFromBytes(base64data, currentHash, null);
}
static string DecryptStringFromBytes(byte[] cipherText, byte[] Key, byte[] IV)
{
// Check arguments.
if (cipherText == null || cipherText.Length <= 0)
throw new ArgumentNullException("cipherText");
if (Key == null || Key.Length <= 0)
throw …Run Code Online (Sandbox Code Playgroud) 我正在尝试在基于 drupal 8 的网站中实现内容搜索功能。我正在使用搜索 API 模块进行内容搜索(https://www.drupal.org/project/search_api)我已经搜索了搜索 API 实现YouTube 上的视频。他们正在创建搜索索引并通过创建视图打印结果。我对内容的网址有疑问。如何获取结果的 url,以便我可以从搜索结果页面导航到该页面。另外,如果特定结果是一个块,我怎样才能获取页面 url?还有其他模块可以提供更好的功能吗?
我正在angularjs 2.0中创建一个示例应用程序.在开发过程中,我遇到了一个严重的问题 - 我无法通过构造函数向组件注入任何东西.
这是plnkr网址:https://plnkr.co/edit/g1UcGmYPLtY8GiXuNHzK ? p = preview
我使用以下代码从app.item.service.ts导入ItemService
import { ItemService } from './app.item.service';
Run Code Online (Sandbox Code Playgroud)
然后我指定提供者为
@Component({
selector: 'list-todo',
template: `
<ul>
<li *ngFor="let item of items">{{item.text}}</li>
</ul>
`,
providers : [ItemService]
})
Run Code Online (Sandbox Code Playgroud)
之后,给TodoComponent的代码为
export class TodoComponent implements OnInit {
items:Array<Object> = [];
constructor(private itemService: ItemService){ //here is the problem
}
ngOnInit(){
this.getItems();
}
getItems(){
this.items = this.itemService.getItems();
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试通过构造函数注入ItemService时,我收到一个错误:"错误:无法解析TodoComponent的所有参数:(?)." 我甚至无法注入像Injector这样的angularjs提供者.
但是,这种方法对我有用:
const injector = ReflectiveInjector.resolveAndCreate([ItemService]);
this.itemService = injector.get(ItemService);
Run Code Online (Sandbox Code Playgroud)
我正在使用我的package.json中提到的以下版本的库进行开发
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0", …Run Code Online (Sandbox Code Playgroud) 我正在使用NativeScript创建一个示例应用程序.我在Android设备中运行应用程序时遇到模板解析错误.
我在模板中的代码只是:
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<Page.actionBar>
<ActionBar title="My ActionBar"/>
</Page.actionBar>
</Page>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Template parse errors:
Only void and foreign elements can be self closed "ActionBar" ("<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<Page.actionBar>
[ERROR ->]<ActionBar title="My ActionBar"/>
</Page.actionBar>
</Page>"): AppComponent@2:6
Error: Template parse errors:
Only void and foreign elements can be self closed "ActionBar" ("<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<Page.actionBar>
[ERROR ->]<ActionBar title="My ActionBar"/>
</Page.actionBar>
</Page>"): AppComponent@2:6
at DirectiveNormalizer.normalizeLoadedTemplate (/data/data/org.nativescript.neurix/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:13506:21)
at /data/data/org.nativescript.neurix/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:13499:53
at ZoneDelegate.invoke (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:190:28)
at Zone.run (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:83:43)
at /data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:449:57
at ZoneDelegate.invokeTask (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:223:37)
at Zone.runTask (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:123:47)
at drainMicroTaskQueue (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:355:35) …Run Code Online (Sandbox Code Playgroud)