RSA与AES混合加密算法的实现

使用 PVRTC 压缩格式创建纹理(Creating textures in the PVRTC compression format)

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es)

本文遵循“署名-非商业用途-保持一致”创作公用协议

转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作。

有关该篇官方文档的相关信息,可以看到很久一直保持应用着,下面具体来看一下 PVRTC 是否能解决纹理加载过程中的延迟大的问题,以便能使其它方法处理结果速度有所提升。

针对于跨平台的 OpenGLES 应用,尚不知这种压缩后的纹理是否能正常工作,有待进一步证实。

技术问答
QA1611

Technical Q&A QA1611

使用 PVRTC 压缩格式创建纹理

Creating textures in the PVRTC compression format

Q:  我如何使用 PVRTC 压缩格式创建纹理?

Q:  How do I create textures in the PVRTC compression format?

A: 我如何使用 PVRTC 压缩格式创建纹理?

A: How do I create textures in the PVRTC compression format?

Important: This document has been superseded by the corresponding chapter Using
Texturetool to Compress Textures
 in the OpenGL
ES Programming Guide for iPhone
. For updates and further information, please refer to that document.

The iPhone SDK includes a tool that allows you to create textures in the PVRTC compression format, aptly named texturetool. If you have Xcode installed with the iPhone OS 2.2
SDK in the default location (/Developer/Platforms/), then texturetool is located at: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool.

texturetool allows you to create four variants of PVRTC data, the primary difference being tradeoffs between quality and size. You will have to experiment with these variants
to determine which setting is the best compromise for each individual texture image.

Important: If you are using PVRTexTool, then you must create textures that are square and a power of two in length. The results of using non-square or non-power-of-two PVRTC
texture data on iPhone OS are undefined.

The parameters that may be passed to texturetool and their function is presented in the rest of this document.

Note: The encoders, formats and options available with texturetool are subject to change.
This document describes those options available as of iPhone OS 2.2. Options not compatible with previous versions of iPhone OS are noted.

Note: The -p option indicates that it requires the -e option. It also requires the -o option.

Listing 1  Encoding Options.

user$ texturetool -l  Encoders:  PVRTC  --channel-weighting-linear  --channel-weighting-perceptual  --bits-per-pixel-2  --bits-per-pixel-4  Formats:  Raw PVR

The texturetool will default to --bits-per-pixel-4--channel-weighting-linear,
and -f Raw if no other options are provided.

The --bits-per-pixel-2 and --bits-per-pixel-4 options create PVRTC data that encodes source
pixels into 2 or 4 bits per pixel. These options represent a fixed 16:1 and 8:1 compression ratio over the uncompressed 32-bit RGBA image data. There is a minimum data size of 32 bytes; the compressor will never produce files smaller than this, and at least
that many bytes are expected when uploading compressed texture data.

When compressing specifying --channel-weighting-linear will spread compression error equally across all channels. By contrast specifying --channel-weighting-perceptual attempts
to reduce error in the green channel compared to the linear option. In general, PVRTC compression does better with photographic images than with line art.

The -m option allows you to automatically generate mipmap levels for the source image. This levels are provided as additional image data in the archive created. If you use the
Raw image format, then each level of image data will be appended one after another to the archive. If you use the PVR archive format, then each mipmap image will be provided as a separate image in the archive.

Warning: Valid PVRTC data is at least 32 bytes in size. This means that images that are 8x8 or smaller will be padded to 32 bytes total before being written to the archive. For example, compressing a 4x4 image consumes 32
bytes, even though it only requires 8 bytes of storage. If you are using the mipmap option with Raw data files, ensure that you take this into consideration as you are reading them.

With iPhone OS 2.2, the texturetool now additional supports a format (-f) parameter that
allows you to control the format of its output file. While this parameter is not available with iPhone OS 2.1 or earlier, the data files produced are compatible with those versions if iPhone OS.

The default format is Raw, which is equivalent to the format that texturetool produced under iPhone SDK 2.0 and 2.1. This format is raw compressed texture data, either for a
single texture level (without the -m option) or for each texture level concatenated together (with the -m option).
Each texture level stored in the file will be at least 32 bytes in size, and must be uploaded to the GPU in its entirety.

The PVR format is the same format that the PVRTexTool from the Imagination Technologies PowerVR SDK produces, and requires parsing to obtain the actual texture data. See the PVRTextureLoader sample
for an example of working with texture data in this format.

Important: Source images for the encoder must satisfy these requirements:

  • Height and Width must be a power of 2.
  • Must be square (height==width).
  • Source images must be in a format that Image IO accepts. This includes PNG, JPG, TIFF and others.

Listing 2  Encoding images into the PVRTC compression format.

Encode Image.png into PVRTC using linear weights and 4 bpp, and saving as ImageL4.pvrtc
user$ texturetool -e PVRTC --channel-weighting-linear --bits-per-pixel-4 -o ImageL4.pvrtc Image.png

Encode Image.png into PVRTC using perceptual weights and 4 bpp, and saving as ImageP4.pvrtc
user$ texturetool -e PVRTC --channel-weighting-perceptual --bits-per-pixel-4 -o ImageP4.pvrtc Image.png

Encode Image.png into PVRTC using linear weights and 2 bpp, and saving as ImageL2.pvrtc
user$ texturetool -e PVRTC --channel-weighting-linear --bits-per-pixel-2 -o ImageL2.pvrtc Image.png

Encode Image.png into PVRTC using perceptual weights and 2 bpp, and saving as ImageP2.pvrtc
user$ texturetool -e PVRTC --channel-weighting-perceptual --bits-per-pixel-2 -o ImageP2.pvrtc Image.png

Listing 3  Encoding images into the PVRTC compression format while creating a preview.

Encode Image.png into PVRTC using linear weights and 4 bpp, and saving the output as ImageL4.pvrtc and a PNG preview as ImageL4.png
user$ texturetool -e PVRTC --channel-weighting-linear --bits-per-pixel-4 -o ImageL4.pvrtc -p ImageL4.png Image.png

Encode Image.png into PVRTC using perceptual weights and 4 bpp, and saving the output as ImageP4.pvrtc and a PNG preview as ImageP4.png
user$ texturetool -e PVRTC --channel-weighting-perceptual --bits-per-pixel-4 -o ImageP4.pvrtc -p ImageP4.png Image.png

Encode Image.png into PVRTC using linear weights and 2 bpp, and saving the output as ImageL2.pvrtc and a PNG preview as ImageL2.png
user$ texturetool -e PVRTC --channel-weighting-linear --bits-per-pixel-2 -o ImageL2.pvrtc -p ImageL2.png Image.png

Encode Image.png into PVRTC using perceptual weights and 2 bpp, and saving the output as ImageP2.pvrtc and a PNG preview as ImageP2.png
user$ texturetool -e PVRTC --channel-weighting-perceptual --bits-per-pixel-2 -o ImageP2.pvrtc -p ImageP2.png Image.png

Note: It is not possible to create a preview without also specifying the -o parameter and a valid output file. Preview images are always in PNG format.

The sample images produced by these settings are shown below.

Table 1  Sample Images.

4bpp, Linear


Original


4bpp, Perceptual

Table 2  Sample Images.

2bpp, Linear


Original


2bpp, Perceptual

Listing 4 demonstrates how you can upload Raw PVRTC data to the GPU via the texImage2DPVRTC sample
function. Typically on iPhone OS you would use NSBundle and NSData methods to load data from a file. For a complete example demonstrating how to upload texture data from a PVR formatted data file, see the PVRTextureLoader sample.

Listing 4  Example of uploading PVRTC data to the graphics chip.

void texImage2DPVRTC(GLint level, GLsizei bpp, GLboolean hasAlpha, GLsizei width, GLsizei height, void *pvrtcData)
{
    GLenum format;
    GLsizei size = width * height * bpp / 8;
    if(hasAlpha) {
        format = (bpp == 4) ? GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG : GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
    } else {
        format = (bpp == 4) ? GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG : GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
    }
    if(size < 32) {
        size = 32;
    }
    glCompressedTexImage2D(GL_TEXTURE_2D, level, format, width, height, 0, size, data);
}

For sample code see the PVRTextureLoader sample.


Document Revision History

Date Notes
2009-07-14
Revised to point to the OpenGL ES Programming Guide. Please refer to that documentation for further updates.

2009-01-27
Clarified non-square texture support (it isn‘t supported). Linked to the PVRTextureLoader sample.

2008-11-24
Changes for iPhone SDK 2.2, which include the new location for the texturetool and new options for its use.

2008-10-13
New document that describes how to create textures in the PVRTC compression format.


Copyright ? 2009 Apple Inc. All Rights Reserved. Terms of Use | Privacy
Policy
 | Updated: 2009-07-14

RSA与AES混合加密算法的实现,布布扣,bubuko.com

时间: 2024-10-03 14:46:03

RSA与AES混合加密算法的实现的相关文章

【C#公共帮助类】给大家分享一些加密算法 (DES、HashCode、RSA、AES等)

AES 高级加密标准(英语:Advanced Encryption Standard,缩写:AES),在密码学中又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准.这个标准用来替代原先的DES,已经被多方分析且广为全世界所使用.AES先进加密算法是一向被认为牢不可破的加密算法,针对这项加密算法的攻击是异常复杂的,事实上想要完全破解AES花费的时间要以数十亿年计,极大的保证了数据的安全性. 这里有两个加密.解密方法: 一种是带密钥的加密:一种是动态加密,就是不需要密钥,密钥被动态生成

Android接口安全 - RSA+AES混合加密方案

转载请注明出处: http://blog.csdn.net/aa464971/article/details/51034462 本文以Androidclient加密提交数据到Java服务端后进行解密为样例. 生成RSA公钥和密钥的方法请參考: http://blog.csdn.net/aa464971/article/details/51035200 Android端的加密思路须要4步: 1.生成AES密钥: 2.使用RSA公钥加密刚刚生成的AES密钥: 3.再使用第1步生成的AES密钥,通过A

混合加密算法(RSA和DES)

一.混合加密的理由 a.前面提及了RSA加解密算法和DES加解密算法这两种加解密算法,由于随着计算机系统能力的不断发展,DES的安全性比它刚出现时会弱得多,追溯历史破解DES的案例层出不穷,一台实际的机器可以在数天内破解DES是让某些人相信他们不能依赖DES的安全性的唯一方法.而相对于DES,RSA的安全性则相对高些,虽然破解RSA的案例也有,但其所付出的代价是相对大的(相对DES),如今RSA的密钥也在升级,这说明破解RSA的难度也在增大. b.在RSA加解密算法中提及到RSA加密明文会受密钥

使用openssl库实现RSA、AES数据加密

使用openssl库实现RSA.AES数据加密 openssl是可以很方便加密解密的库,可以使用它来对需要在网络中传输的数据加密.可以使用非对称加密:公钥加密,私钥解密.openssl提供了对RSA的支持,但RSA存在计算效率低的问题,所以一般的做法是使用对称密钥加密数据,然后再把这个只在当前有效的临时生成的对称密钥用非对称密钥的公钥加密之后传递给目标方,目标方使用约定好的非对称密钥中的私钥解开,得到数据加密的密钥,再进行数据解密,得到数据,这种使用方式很常见,可以认为是对HTTPS的裁剪.对称

Java 加密 AES 对称加密算法

题目链接:https://oj.leetcode.com/problems/set-matrix-zeroes/ Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 一个个找肯定会超时,我们可以分别用一个行向量和一个列向量进行维护.这样O(m*n) 能出来 class Solution { public: void setZeroes(vector<vector

AES可逆加密算法

分享一段前段时间看到的AES可逆加密算法. 除去常见的MD5等加密方式,如果想要使用一些更加隐蔽的加密方式,则可以使用AES的RijndaelManaged加密算法. 关于加密,有很多复杂的算法,今天只跟大家分享一段摘取的结合动态密钥的对称AES RijndaelManaged加密解密算法,如果大家有兴趣了解更多,我们可以一起深入研究…… static void Main(string[] args) { string key = "8H[=}[email protected](";

AES 可逆性加密算法

AES 可逆性加密算法 package com.lock.demo.service; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; /** * @author niunafei * @function

浅析DES与AES、RSA三种典型加密算法的比较

DES与AES的比较 自DES 算法公诸于世以来,学术界围绕它的安全性等方面进行了研究并展开了激烈的争论.在技术上,对DES的批评主要集中在以下几个方面: 1.作为分组密码,DES 的加密单位仅有64 位二进制,这对于数据传输来说太小,因为每个分组仅含8 个字符,而且其中某些位还要用于奇偶校验或其他通讯开销. 2.DES 的密钥的位数太短,只有56 比特,而且各次迭代中使用的密钥是递推产生的,这种相关必然降低密码体制的安全性,在现有技术下用穷举法寻找密钥已趋于可行. 3.DES 不能对抗差分和线

AES对称加密算法原理

原著:James McCaffrey 翻译:小刀人 原文出处:MSDN Magazine November 2003 (Encrypt It) 本文的代码下载:msdnmag200311AES.exe (143KB) 本文假设你熟悉 C# 和 位(bit)操作. 摘要 AES(The Advanced Encryption Standard)是美国国家标准与技术研究所用于加密电子数据的规范.它被预期能成为人们公认的加密包括金融.电信和政府数字信息的方法.本文展示了AES的概貌并解析了它使用的算法