小编DTs*_*DTs的帖子

PBKDF2WithHmacSHA512比.PBKDF2WithHmacSHA1

我正在研究一个Java身份验证子系统,该子系统规定在DB中存储密码作为PBKDF2生成的哈希,我现在正在尝试决定是否应该使用SHA1SHA512作为PFR.我仔细检查了两者的规格,但我们在数学上非常密集地跟随它.有更好的加密理解的人可以解释一下有什么PBKDF2WithHmacSHA512不同PBKDF2WithHmacSHA1吗?

这是我正在尝试做的事情:

private static final int HASH_BYTE_SIZE = 64; // 512 bits
private static final int PBKDF2_ITERATIONS = 1000;      

// generate random salt
SecureRandom random = new SecureRandom();
byte salt[] = new byte[SALT_BYTE_SIZE]; // use salt size at least as long as hash
random.nextBytes(salt);

// generate Hash
PBEKeySpec spec = new PBEKeySpec(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE);
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); // we would like this to be "PBKDF2WithHmacSHA512" instead? What Provider …
Run Code Online (Sandbox Code Playgroud)

java pbkdf2 secret-key javax.crypto

23
推荐指数
1
解决办法
3万
查看次数

如何在iOS5之前执行[UIImage resizableImageWithCapInsets:]?

以下代码在指定的insets中平铺图像区域:

UIEdgeInsets imgInsets = UIEdgeInsetsMake(10.f, 5.f, 13.f, 44.f);
UIImage *image = [[UIImage imageNamed:@"fileName"] resizableImageWithCapInsets:imgInsets]; 
Run Code Online (Sandbox Code Playgroud)

但是,这仅适用于iOS5.如何在兼容iOS5之前获得相同的结果?

[UIImage stretchableImageWithLeftCapWidth: topCapHeight:]据我所知,它是不合适的,因为它假设可平铺区域是1px宽.换句话说,它不会平铺,它会拉伸.因此,它不适用于图案,仅适用于单色图像.这将在下面的屏幕截图中演示.

然后有[UIColor colorWithPatternImage:],但这假设整个图像需要平铺,它不允许必须保持上限的插图.

任何帮助表示感谢,谢谢.

.

在此输入图像描述

uiimage ios ios5

12
推荐指数
1
解决办法
5132
查看次数

如何更改CGPDFPageRef的背景颜色,以及如何删除页面的阴影

我试图用a UIWebView而不是a 来绘制内容UIView,因为我喜欢UIWebView通过捏合放大和缩小的能力.这是我的代码:

// setup environment
CGRect outputRect = myWebView.bounds;
CFMutableDataRef data = CFDataCreateMutable(NULL, 0); // init with default allocator and unlimited size
CGDataConsumerRef dataConsumer = CGDataConsumerCreateWithCFData(data);
CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, &outputRect, NULL);

CGPDFContextBeginPage(pdfContext, NULL);

// draw something
CGContextSetRGBFillColor (pdfContext, 1, 0, 0, 1);
CGContextFillRect (pdfContext, CGRectMake (0, 0, 200, 100 ));
CGContextSetRGBFillColor (pdfContext, 0, 0, 1, .5);
CGContextFillRect (pdfContext, CGRectMake (0, 0, 100, 200 ));

CGPDFContextEndPage(pdfContext);

// load drawing in webView
[myWebView loadData:(NSData *)data …
Run Code Online (Sandbox Code Playgroud)

pdf-generation uiwebview cgpdfdocument ios cgpdf

0
推荐指数
1
解决办法
1298
查看次数