我有这个加密密码的脚本,但我不知道如何反转它并解密它.这可能是一个非常简单的答案,但我不明白该怎么做.
#!/usr/bin/perl
use Crypt::Eksblowfish::Bcrypt;
use Crypt::Random;
$password = 'bigtest';
$encrypted = encrypt_password($password);
print "$password is encrypted as $encrypted\n";
print "Yes the password is $password\n" if check_password($password, $encrypted);
print "No the password is not smalltest\n" if !check_password('smalltest', $encrypted);
# Encrypt a password
sub encrypt_password {
my $password = shift;
# Generate a salt if one is not passed
my $salt = shift || salt();
# Set the cost to 8 and append a NUL
my $settings = '$2a$08$'.$salt;
# Encrypt it …
Run Code Online (Sandbox Code Playgroud) 我是制作bash脚本的新手,但我的目标是获取一个.txt文件,并将txt文件中的字符串分配给变量.我试过这个(如果我在正确的轨道上没有线索).
#!/bin/bash
FILE="answer.txt"
file1="cat answer.txt"
print $file1
Run Code Online (Sandbox Code Playgroud)
当我跑这个时,我明白了
Warning: unknown mime-type for "cat" -- using "application/octet-stream"
Error: no such file "cat"
Error: no "print" mailcap rules found for type "text/plain"
Run Code Online (Sandbox Code Playgroud)
我能做些什么来完成这项工作?
编辑**当我将其更改为:
#!/bin/bash
FILE="answer.txt"
file1=$(cat answer.txt)
print $file1
Run Code Online (Sandbox Code Playgroud)
我得到了这个:
Warning: unknown mime-type for "This" -- using "application/octet-stream"
Warning: unknown mime-type for "text" -- using "application/octet-stream"
Warning: unknown mime-type for "string" -- using "application/octet-stream"
Warning: unknown mime-type for "should" -- using "application/octet-stream"
Warning: unknown mime-type for "be" -- using "application/octet-stream"
Warning: …
Run Code Online (Sandbox Code Playgroud) 现在我在这里使用这个项目.它是一个python脚本,使用webrtc运行服务器,将客户端/浏览器网络摄像头发送到服务器并执行面部识别.我想做的是使用连接到pi的网络摄像头或pi摄像头做同样的事情,但不使用浏览器.有没有办法用当前的设置做到这一点,还是有更好的方法来实现这一目标?
我从github 使用这个项目,它是一个图像选择器.我不得不做一个非常小的改动,因为ios7使你的专辑中的预览图像再次显示但是现在当你离开选择器然后回到它时所选择的照片(2/5)重置为0/5甚至虽然我选择了照片.我怎样才能解决这个问题?
在dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0)
似乎一直无法进行更新UI即使dispatch_async(dispatch_get_main_queue()
重新加载它里面的UI.当我注释掉dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0)
这些图片时会立即加载,但其他东西会因为队列而被破坏.
这里是代码片段,dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0)
我改变了代码我改变了注释掉了
AGIPCAssetsController.m:
- (void)loadAssets
{
[self.assets removeAllObjects];
__ag_weak AGIPCAssetsController *weakSelf = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
__strong AGIPCAssetsController *strongSelf = weakSelf;
@autoreleasepool {
[strongSelf.assetsGroup enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (result == nil)
{
return;
}
AGIPCGridItem *gridItem = [[AGIPCGridItem alloc] initWithImagePickerController:strongSelf.imagePickerController asset:result andDelegate:strongSelf];
if ( strongSelf.imagePickerController.selection != nil &&
[strongSelf.imagePickerController.selection containsObject:result])
{
gridItem.selected = YES;
}
[strongSelf.assets addObject:gridItem];
}];
}
dispatch_async(dispatch_get_main_queue(), …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的coredata转换为json,我一直在努力让这个工作,但已找到一种几乎正常工作的方式.
我的代码:
NSArray *keys = [[[self.form entity] attributesByName] allKeys];
NSDictionary *dict = [self.form dictionaryWithValuesForKeys:keys];
NSLog(@"dict::%@",dict);
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
error:&error];
if (! jsonData) {
NSLog(@"Got an error: %@", error);
} else {
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"json::%@",jsonString);
}
Run Code Online (Sandbox Code Playgroud)
"形式"也是:
@property (strong, retain) NSManagedObject *form;
Run Code Online (Sandbox Code Playgroud)
除了我在某些coredata属性中保存了NSIndexSet之外,这个工作正常.这给JSON写入带来了问题.现在,我的索引集不需要转换为json所以我想知道是否有办法从dict中删除所有索引?或者有更好的方法来做到这一点,我不知道.
这是dlog的nslog的一部分:
...
whereExtent = "";
wiring = (
);
wiring1 = "<NSIndexSet: 0x82b0600>(no indexes)"; …
Run Code Online (Sandbox Code Playgroud) 我有一个预览点,可以在上传之前显示图像的预览,问题是当您从手机中选择图像时它会出现在侧面.如果需要旋转图像,如何旋转图像?
我的javascript来显示预览:
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah')
.attr('src', e.target.result)
};
reader.readAsDataURL(input.files[0]);
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
和HTML
<img src="images/Your_Picture_Here.png" alt="" title="" class="prod_image" id = "blah"/>
Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的nsmutablearray:
(
{
caption = "";
urlRep = "assets-library://asset/asset.JPG?id=6FC0C2DC-69BB-4FAD-9709-63E03182BEE1&ext=JPG";
},
{
caption = "";
urlRep = "assets-library://asset/asset.JPG?id=324E4377-0BCD-431C-8A57-535BC0FC44EB&ext=JPG";
}
)
Run Code Online (Sandbox Code Playgroud)
我试图像这样设置标题的值:
[[[self.form valueForKey:@"photos"] objectAtIndex:indexPath.row] setValue:@"hi" forKey:@"caption"];
Run Code Online (Sandbox Code Playgroud)
([self.form valueForKey:@"photos"]
是数组)
但我得到:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionaryI 0xa68ec40> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key caption.'
Run Code Online (Sandbox Code Playgroud)
编辑:
如果我使用setObject forKey我得到:
-[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance 0xa6a88f0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance …
Run Code Online (Sandbox Code Playgroud) 我有2个数组:
private String[] placeName;
private Double[] miles;
Run Code Online (Sandbox Code Playgroud)
它们中的数据如下所示:
placeName = {"home", "away", "here"};
miles = {111, 11, 3};
Run Code Online (Sandbox Code Playgroud)
值的位置彼此匹配。例如,家= 111,客场= 11
我需要将这些数组排序在一起,以免丢失最低到最高数字对它们的匹配方式。做到这一点的最佳方法是什么?我需要先合并数组吗?
我有一个变量$photo
(已经被base64编码的巨大字符串),我相信我需要使用这样的方法解码它MIME::Base64
:
my $decoded= MIME::Base64::decode_base64($photo);
Run Code Online (Sandbox Code Playgroud)
现在之后我怎么把$解码回原来的jpg?
我试图在perl中创建一个json字符串,输出如下内容:
{"d":{"success":false, "error":"key is required"}}
Run Code Online (Sandbox Code Playgroud)
我已经想出了如何在没有使用这个例子的"d"的情况下做到这一点:
my %rec_hash = ('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
my $json = encode_json \%rec_hash;
print "$json\n";
Run Code Online (Sandbox Code Playgroud)
但不确定我想要用额外的水平做什么
ios ×3
perl ×3
arrays ×1
base64 ×1
bash ×1
bcrypt ×1
core-data ×1
iphone ×1
java ×1
javascript ×1
json ×1
objective-c ×1
python ×1
raspberry-pi ×1
webrtc ×1