我正在研究一个Java身份验证子系统,该子系统规定在DB中存储密码作为PBKDF2生成的哈希,我现在正在尝试决定是否应该使用SHA1或SHA512作为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) 以下代码在指定的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:],但这假设整个图像需要平铺,它不允许必须保持上限的插图.
任何帮助表示感谢,谢谢.
.

我试图用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) ios ×2
cgpdf ×1
ios5 ×1
java ×1
javax.crypto ×1
pbkdf2 ×1
secret-key ×1
uiimage ×1
uiwebview ×1